Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input

Pull input updates from Dmitry Torokhov:

- three new touchscreen drivers: Hycon HY46XX, ILITEK Lego Series,
and MStar MSG2638

- a new driver for Azoteq IQS626A proximity and touch controller

- addition of Amazon Game Controller to the list of devices handled
by the xpad driver

- Elan touchscreen driver will avoid binding to devices described as
I2CHID compatible in ACPI tables

- various driver fixes

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (56 commits)
Input: xpad - add support for Amazon Game Controller
Input: ili210x - add missing negation for touch indication on ili210x
MAINTAINERS: repair reference in HYCON HY46XX TOUCHSCREEN SUPPORT
Input: add driver for the Hycon HY46XX touchpanel series
dt-bindings: touchscreen: Add HY46XX bindings
dt-bindings: Add Hycon Technology vendor prefix
Input: cyttsp - flag the device properly
Input: cyttsp - set abs params for ABS_MT_TOUCH_MAJOR
Input: cyttsp - drop the phys path
Input: cyttsp - reduce reset pulse timings
Input: cyttsp - error message on boot mode exit error
Input: apbps2 - remove useless variable
Input: mms114 - support MMS136
Input: mms114 - convert bindings to YAML and extend
Input: Add support for ILITEK Lego Series
dt-bindings: input: touchscreen: ilitek_ts_i2c: Add bindings
Input: add MStar MSG2638 touchscreen driver
dt-bindings: input/touchscreen: add bindings for msg2638
Input: silead - add workaround for x86 BIOS-es which bring the chip up in a stuck state
Input: elants_i2c - do not bind to i2c-hid compatible ACPI instantiated devices
...

+5481 -549
+9
Documentation/ABI/testing/sysfs-driver-input-exc3000
··· 15 15 Access: Read 16 16 17 17 Valid values: Represented as string 18 + 19 + What: /sys/bus/i2c/devices/xxx/type 20 + Date: Jan 2021 21 + Contact: linux-input@vger.kernel.org 22 + Description: Reports the type identification provided by the touchscreen, for example "PCAP82H80 Series" 23 + 24 + Access: Read 25 + 26 + Valid values: Represented as string
+32
Documentation/devicetree/bindings/input/atmel,maxtouch.yaml
··· 39 39 (active low). The line must be flagged with 40 40 GPIO_ACTIVE_LOW. 41 41 42 + wake-gpios: 43 + maxItems: 1 44 + description: 45 + Optional GPIO specifier for the touchscreen's wake pin 46 + (active low). The line must be flagged with 47 + GPIO_ACTIVE_LOW. 48 + 42 49 linux,gpio-keymap: 43 50 $ref: /schemas/types.yaml#/definitions/uint32-array 44 51 description: | ··· 60 53 or experiment to determine which bit corresponds to which input. Use 61 54 KEY_RESERVED for unused padding values. 62 55 56 + atmel,wakeup-method: 57 + $ref: /schemas/types.yaml#/definitions/uint32 58 + description: | 59 + The WAKE line is an active-low input that is used to wake up the touch 60 + controller from deep-sleep mode before communication with the controller 61 + could be started. This optional feature used to minimize current 62 + consumption when the controller is in deep sleep mode. This feature is 63 + relevant only to some controller families, like mXT1386 controller for 64 + example. 65 + 66 + The WAKE pin can be connected in one of the following ways: 67 + 1) left permanently low 68 + 2) connected to the I2C-compatible SCL pin 69 + 3) connected to a GPIO pin on the host 70 + enum: 71 + - 0 # ATMEL_MXT_WAKEUP_NONE 72 + - 1 # ATMEL_MXT_WAKEUP_I2C_SCL 73 + - 2 # ATMEL_MXT_WAKEUP_GPIO 74 + default: 0 75 + 76 + wakeup-source: 77 + type: boolean 78 + 63 79 required: 64 80 - compatible 65 81 - reg ··· 93 63 examples: 94 64 - | 95 65 #include <dt-bindings/interrupt-controller/irq.h> 66 + #include <dt-bindings/input/atmel-maxtouch.h> 96 67 #include <dt-bindings/gpio/gpio.h> 97 68 i2c { 98 69 #address-cells = <1>; ··· 106 75 reset-gpios = <&gpio 27 GPIO_ACTIVE_LOW>; 107 76 vdda-supply = <&ab8500_ldo_aux2_reg>; 108 77 vdd-supply = <&ab8500_ldo_aux5_reg>; 78 + atmel,wakeup-method = <ATMEL_MXT_WAKEUP_I2C_SCL>; 109 79 }; 110 80 }; 111 81
+843
Documentation/devicetree/bindings/input/iqs626a.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/input/iqs626a.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Azoteq IQS626A Capacitive Touch Controller 8 + 9 + maintainers: 10 + - Jeff LaBundy <jeff@labundy.com> 11 + 12 + description: | 13 + The Azoteq IQS626A is a 14-channel capacitive touch controller that features 14 + additional Hall-effect and inductive sensing capabilities. 15 + 16 + Link to datasheet: https://www.azoteq.com/ 17 + 18 + allOf: 19 + - $ref: touchscreen/touchscreen.yaml# 20 + 21 + properties: 22 + compatible: 23 + const: azoteq,iqs626a 24 + 25 + reg: 26 + maxItems: 1 27 + 28 + interrupts: 29 + maxItems: 1 30 + 31 + "#address-cells": 32 + const: 1 33 + 34 + "#size-cells": 35 + const: 0 36 + 37 + azoteq,suspend-mode: 38 + $ref: /schemas/types.yaml#/definitions/uint32 39 + enum: [0, 1, 2, 3] 40 + default: 0 41 + description: | 42 + Specifies the power mode during suspend as follows: 43 + 0: Automatic (same as normal runtime, i.e. suspend/resume disabled) 44 + 1: Low power (all sensing at a reduced reporting rate) 45 + 2: Ultra-low power (ULP channel proximity sensing) 46 + 3: Halt (no sensing) 47 + 48 + azoteq,clk-div: 49 + type: boolean 50 + description: Divides the device's core clock by a factor of 4. 51 + 52 + azoteq,ulp-enable: 53 + type: boolean 54 + description: 55 + Permits the device to automatically enter ultra-low-power mode from low- 56 + power mode. 57 + 58 + azoteq,ulp-update: 59 + $ref: /schemas/types.yaml#/definitions/uint32 60 + enum: [0, 1, 2, 3, 4, 5, 6, 7] 61 + default: 3 62 + description: | 63 + Specifies the rate at which the trackpad, generic and Hall channels are 64 + updated during ultra-low-power mode as follows: 65 + 0: 8 66 + 1: 13 67 + 2: 28 68 + 3: 54 69 + 4: 89 70 + 5: 135 71 + 6: 190 72 + 7: 256 73 + 74 + azoteq,ati-band-disable: 75 + type: boolean 76 + description: Disables the ATI band check. 77 + 78 + azoteq,ati-lp-only: 79 + type: boolean 80 + description: Limits automatic ATI to low-power mode. 81 + 82 + azoteq,gpio3-select: 83 + $ref: /schemas/types.yaml#/definitions/uint32 84 + enum: [0, 1, 2, 3, 4, 5, 6, 7] 85 + default: 1 86 + description: | 87 + Selects the channel or group of channels for which the GPIO3 pin 88 + represents touch state as follows: 89 + 0: None 90 + 1: ULP channel 91 + 2: Trackpad 92 + 3: Trackpad 93 + 4: Generic channel 0 94 + 5: Generic channel 1 95 + 6: Generic channel 2 96 + 7: Hall channel 97 + 98 + azoteq,reseed-select: 99 + $ref: /schemas/types.yaml#/definitions/uint32 100 + enum: [0, 1, 2, 3] 101 + default: 0 102 + description: | 103 + Specifies the event(s) that prompt the device to reseed (i.e. reset the 104 + long-term average) of an associated channel as follows: 105 + 0: None 106 + 1: Proximity 107 + 2: Proximity or touch 108 + 3: Proximity, touch or deep touch 109 + 110 + azoteq,thresh-extend: 111 + type: boolean 112 + description: Multiplies all touch and deep-touch thresholds by 4. 113 + 114 + azoteq,tracking-enable: 115 + type: boolean 116 + description: 117 + Enables all associated channels to track their respective reference 118 + channels. 119 + 120 + azoteq,reseed-offset: 121 + type: boolean 122 + description: 123 + Applies an 8-count offset to all long-term averages upon either ATI or 124 + reseed events. 125 + 126 + azoteq,rate-np-ms: 127 + minimum: 0 128 + maximum: 255 129 + default: 150 130 + description: Specifies the report rate (in ms) during normal-power mode. 131 + 132 + azoteq,rate-lp-ms: 133 + minimum: 0 134 + maximum: 255 135 + default: 150 136 + description: Specifies the report rate (in ms) during low-power mode. 137 + 138 + azoteq,rate-ulp-ms: 139 + multipleOf: 16 140 + minimum: 0 141 + maximum: 4080 142 + default: 0 143 + description: Specifies the report rate (in ms) during ultra-low-power mode. 144 + 145 + azoteq,timeout-pwr-ms: 146 + multipleOf: 512 147 + minimum: 0 148 + maximum: 130560 149 + default: 2560 150 + description: 151 + Specifies the length of time (in ms) to wait for an event before moving 152 + from normal-power mode to low-power mode, or (if 'azoteq,ulp-enable' is 153 + present) from low-power mode to ultra-low-power mode. 154 + 155 + azoteq,timeout-lta-ms: 156 + multipleOf: 512 157 + minimum: 0 158 + maximum: 130560 159 + default: 40960 160 + description: 161 + Specifies the length of time (in ms) to wait before resetting the long- 162 + term average of all channels. Specify the maximum timeout to disable it 163 + altogether. 164 + 165 + touchscreen-inverted-x: true 166 + touchscreen-inverted-y: true 167 + touchscreen-swapped-x-y: true 168 + 169 + patternProperties: 170 + "^ulp-0|generic-[0-2]|hall$": 171 + type: object 172 + description: 173 + Represents a single sensing channel. A channel is active if defined and 174 + inactive otherwise. 175 + 176 + properties: 177 + azoteq,ati-exclude: 178 + type: boolean 179 + description: 180 + Prevents the channel from participating in an ATI event that is 181 + manually triggered during initialization. 182 + 183 + azoteq,reseed-disable: 184 + type: boolean 185 + description: 186 + Prevents the channel from being reseeded if the long-term average 187 + timeout (defined in 'azoteq,timeout-lta') expires. 188 + 189 + azoteq,meas-cap-decrease: 190 + type: boolean 191 + description: 192 + Decreases the internal measurement capacitance from 60 pF to 15 pF. 193 + 194 + azoteq,rx-inactive: 195 + $ref: /schemas/types.yaml#/definitions/uint32 196 + enum: [0, 1, 2] 197 + default: 0 198 + description: | 199 + Specifies how inactive CRX pins are to be terminated as follows: 200 + 0: VSS 201 + 1: Floating 202 + 2: VREG (generic channels only) 203 + 204 + azoteq,linearize: 205 + type: boolean 206 + description: 207 + Enables linearization of the channel's counts (generic and Hall 208 + channels) or inverts the polarity of the channel's proximity or 209 + touch states (ULP channel). 210 + 211 + azoteq,dual-direction: 212 + type: boolean 213 + description: 214 + Specifies that the channel's long-term average is to freeze in the 215 + presence of either increasing or decreasing counts, thereby permit- 216 + ting events to be reported in either direction. 217 + 218 + azoteq,filt-disable: 219 + type: boolean 220 + description: Disables raw count filtering for the channel. 221 + 222 + azoteq,ati-mode: 223 + $ref: /schemas/types.yaml#/definitions/uint32 224 + enum: [0, 1, 2, 3] 225 + description: | 226 + Specifies the channel's ATI mode as follows: 227 + 0: Disabled 228 + 1: Semi-partial 229 + 2: Partial 230 + 3: Full 231 + 232 + The default value is a function of the channel and the device's reset 233 + user interface (RUI); reference the datasheet for further information 234 + about the available RUI options. 235 + 236 + azoteq,ati-base: 237 + $ref: /schemas/types.yaml#/definitions/uint32 238 + enum: [75, 100, 150, 200] 239 + description: 240 + Specifies the channel's ATI base. The default value is a function 241 + of the channel and the device's RUI. 242 + 243 + azoteq,ati-target: 244 + $ref: /schemas/types.yaml#/definitions/uint32 245 + multipleOf: 32 246 + minimum: 0 247 + maximum: 2016 248 + description: 249 + Specifies the channel's ATI target. The default value is a function 250 + of the channel and the device's RUI. 251 + 252 + azoteq,cct-increase: 253 + $ref: /schemas/types.yaml#/definitions/uint32 254 + minimum: 0 255 + maximum: 16 256 + default: 0 257 + description: 258 + Specifies the degree to which the channel's charge cycle time is to 259 + be increased, with 0 representing no increase. The maximum value is 260 + limited to 4 in the case of the ULP channel, and the property is un- 261 + available entirely in the case of the Hall channel. 262 + 263 + azoteq,proj-bias: 264 + $ref: /schemas/types.yaml#/definitions/uint32 265 + enum: [0, 1, 2, 3] 266 + default: 0 267 + description: | 268 + Specifies the bias current applied during projected-capacitance 269 + sensing as follows: 270 + 0: 2.5 uA 271 + 1: 5 uA 272 + 2: 10 uA 273 + 3: 20 uA 274 + 275 + This property is unavailable in the case of the Hall channel. 276 + 277 + azoteq,sense-freq: 278 + $ref: /schemas/types.yaml#/definitions/uint32 279 + enum: [0, 1, 2, 3] 280 + description: | 281 + Specifies the channel's sensing frequency as follows (parenthesized 282 + numbers represent the frequency if 'azoteq,clk-div' is present): 283 + 0: 4 MHz (1 MHz) 284 + 1: 2 MHz (500 kHz) 285 + 2: 1 MHz (250 kHz) 286 + 3: 500 kHz (125 kHz) 287 + 288 + This property is unavailable in the case of the Hall channel. The 289 + default value is a function of the channel and the device's RUI. 290 + 291 + azoteq,ati-band-tighten: 292 + type: boolean 293 + description: 294 + Tightens the ATI band from 1/8 to 1/16 of the desired target (ULP and 295 + generic channels only). 296 + 297 + azoteq,proj-enable: 298 + type: boolean 299 + description: Enables projected-capacitance sensing (ULP channel only). 300 + 301 + azoteq,filt-str-np-cnt: 302 + $ref: /schemas/types.yaml#/definitions/uint32 303 + enum: [0, 1, 2, 3] 304 + default: 0 305 + description: 306 + Specifies the raw count filter strength during normal-power mode (ULP 307 + and generic channels only). 308 + 309 + azoteq,filt-str-lp-cnt: 310 + $ref: /schemas/types.yaml#/definitions/uint32 311 + enum: [0, 1, 2, 3] 312 + default: 0 313 + description: 314 + Specifies the raw count filter strength during low-power mode (ULP and 315 + generic channels only). 316 + 317 + azoteq,filt-str-np-lta: 318 + $ref: /schemas/types.yaml#/definitions/uint32 319 + enum: [0, 1, 2, 3] 320 + default: 0 321 + description: 322 + Specifies the long-term average filter strength during normal-power 323 + mode (ULP and generic channels only). 324 + 325 + azoteq,filt-str-lp-lta: 326 + $ref: /schemas/types.yaml#/definitions/uint32 327 + enum: [0, 1, 2, 3] 328 + default: 0 329 + description: 330 + Specifies the long-term average filter strength during low-power mode 331 + (ULP and generic channels only). 332 + 333 + azoteq,rx-enable: 334 + $ref: /schemas/types.yaml#/definitions/uint32-array 335 + minItems: 1 336 + maxItems: 8 337 + items: 338 + minimum: 0 339 + maximum: 7 340 + description: 341 + Specifies the CRX pin(s) associated with the channel. 342 + 343 + This property is unavailable in the case of the Hall channel. The 344 + default value is a function of the channel and the device's RUI. 345 + 346 + azoteq,tx-enable: 347 + $ref: /schemas/types.yaml#/definitions/uint32-array 348 + minItems: 1 349 + maxItems: 8 350 + items: 351 + minimum: 0 352 + maximum: 7 353 + description: 354 + Specifies the TX pin(s) associated with the channel. 355 + 356 + This property is unavailable in the case of the Hall channel. The 357 + default value is a function of the channel and the device's RUI. 358 + 359 + azoteq,local-cap-size: 360 + $ref: /schemas/types.yaml#/definitions/uint32 361 + enum: [0, 1, 2, 3, 4] 362 + default: 0 363 + description: | 364 + Specifies the capacitance to be added to the channel as follows: 365 + 0: 0 pF 366 + 1: 0.5 pF 367 + 2: 1.0 pF 368 + 3: 1.5 pF 369 + 4: 2.0 pF 370 + 371 + This property is unavailable in the case of the ULP or Hall channels. 372 + 373 + azoteq,sense-mode: 374 + $ref: /schemas/types.yaml#/definitions/uint32 375 + enum: [0, 1, 8, 9, 12, 14, 15] 376 + description: | 377 + Specifies the channel's sensing mode as follows: 378 + 0: Self capacitance 379 + 1: Projected capacitance 380 + 8: Self inductance 381 + 9: Mutual inductance 382 + 12: External 383 + 14: Hall effect 384 + 15: Temperature 385 + 386 + This property is unavailable in the case of the ULP or Hall channels. 387 + The default value is a function of the channel and the device's RUI. 388 + 389 + azoteq,tx-freq: 390 + $ref: /schemas/types.yaml#/definitions/uint32 391 + enum: [0, 1, 2, 3] 392 + default: 0 393 + description: | 394 + Specifies the inductive sensing excitation frequency as follows 395 + (parenthesized numbers represent the frequency if 'azoteq,clk-div' 396 + is present): 397 + 0: 16 MHz (4 MHz) 398 + 1: 8 MHz (2 MHz) 399 + 2: 4 MHz (1 MHz) 400 + 3: 2 MHz (500 kHz) 401 + 402 + This property is unavailable in the case of the ULP or Hall channels. 403 + 404 + azoteq,invert-enable: 405 + type: boolean 406 + description: 407 + Inverts the polarity of the states reported for proximity, touch and 408 + deep-touch events relative to their respective thresholds (generic 409 + channels only). 410 + 411 + azoteq,comp-disable: 412 + type: boolean 413 + description: 414 + Disables compensation for the channel (generic channels only). 415 + 416 + azoteq,static-enable: 417 + type: boolean 418 + description: 419 + Enables the static front-end for the channel (generic channels only). 420 + 421 + azoteq,assoc-select: 422 + $ref: /schemas/types.yaml#/definitions/string-array 423 + minItems: 1 424 + maxItems: 6 425 + items: 426 + enum: 427 + - ulp-0 428 + - trackpad-3x2 429 + - trackpad-3x3 430 + - generic-0 431 + - generic-1 432 + - generic-2 433 + - hall 434 + description: 435 + Specifies the associated channels for which the channel serves as a 436 + reference channel. By default, no channels are selected. This prop- 437 + erty is only available for the generic channels. 438 + 439 + azoteq,assoc-weight: 440 + $ref: /schemas/types.yaml#/definitions/uint32 441 + minimum: 0 442 + maximum: 255 443 + default: 0 444 + description: 445 + Specifies the channel's impact weight if it acts as an associated 446 + channel (0 = 0% impact, 255 = 200% impact). This property is only 447 + available for the generic channels. 448 + 449 + patternProperties: 450 + "^event-(prox|touch|deep)(-alt)?$": 451 + type: object 452 + description: 453 + Represents a proximity, touch or deep-touch event reported by the 454 + channel in response to a decrease in counts. Node names suffixed with 455 + '-alt' instead correspond to an increase in counts. 456 + 457 + By default, the long-term average tracks an increase in counts such 458 + that only events corresponding to a decrease in counts are reported 459 + (refer to the datasheet for more information). 460 + 461 + Specify 'azoteq,dual-direction' to freeze the long-term average when 462 + the counts increase or decrease such that events of either direction 463 + can be reported. Alternatively, specify 'azoteq,invert-enable' to in- 464 + vert the polarity of the states reported by the channel. 465 + 466 + Complementary events (e.g. event-touch and event-touch-alt) can both 467 + be present and specify different key or switch codes, but not differ- 468 + ent thresholds or hysteresis (if applicable). 469 + 470 + Proximity events are unavailable in the case of the Hall channel, and 471 + deep-touch events are only available for the generic channels. Unless 472 + otherwise specified, default values are a function of the channel and 473 + the device's RUI. 474 + 475 + properties: 476 + azoteq,thresh: 477 + $ref: /schemas/types.yaml#/definitions/uint32 478 + minimum: 0 479 + maximum: 255 480 + description: Specifies the threshold for the event. 481 + 482 + azoteq,hyst: 483 + $ref: /schemas/types.yaml#/definitions/uint32 484 + minimum: 0 485 + maximum: 15 486 + description: 487 + Specifies the hysteresis for the event (touch and deep-touch 488 + events only). 489 + 490 + linux,code: 491 + $ref: /schemas/types.yaml#/definitions/uint32 492 + description: Numeric key or switch code associated with the event. 493 + 494 + linux,input-type: 495 + $ref: /schemas/types.yaml#/definitions/uint32 496 + enum: [1, 5] 497 + description: 498 + Specifies whether the event is to be interpreted as a key (1) or 499 + a switch (5). By default, Hall-channel events are interpreted as 500 + switches and all others are interpreted as keys. 501 + 502 + dependencies: 503 + linux,input-type: ["linux,code"] 504 + 505 + additionalProperties: false 506 + 507 + dependencies: 508 + azoteq,assoc-weight: ["azoteq,assoc-select"] 509 + 510 + additionalProperties: false 511 + 512 + "^trackpad-3x[2-3]$": 513 + type: object 514 + description: 515 + Represents all channels associated with the trackpad. The channels are 516 + collectively active if the trackpad is defined and inactive otherwise. 517 + 518 + properties: 519 + azoteq,ati-exclude: 520 + type: boolean 521 + description: 522 + Prevents the trackpad channels from participating in an ATI event 523 + that is manually triggered during initialization. 524 + 525 + azoteq,reseed-disable: 526 + type: boolean 527 + description: 528 + Prevents the trackpad channels from being reseeded if the long-term 529 + average timeout (defined in 'azoteq,timeout-lta') expires. 530 + 531 + azoteq,meas-cap-decrease: 532 + type: boolean 533 + description: 534 + Decreases the internal measurement capacitance from 60 pF to 15 pF. 535 + 536 + azoteq,rx-inactive: 537 + $ref: /schemas/types.yaml#/definitions/uint32 538 + enum: [0, 1] 539 + default: 0 540 + description: | 541 + Specifies how inactive CRX pins are to be terminated as follows: 542 + 0: VSS 543 + 1: Floating 544 + 545 + azoteq,linearize: 546 + type: boolean 547 + description: Inverts the polarity of the trackpad's touch state. 548 + 549 + azoteq,dual-direction: 550 + type: boolean 551 + description: 552 + Specifies that the trackpad's long-term averages are to freeze in 553 + the presence of either increasing or decreasing counts, thereby 554 + permitting events to be reported in either direction. 555 + 556 + azoteq,filt-disable: 557 + type: boolean 558 + description: Disables raw count filtering for the trackpad channels. 559 + 560 + azoteq,ati-mode: 561 + $ref: /schemas/types.yaml#/definitions/uint32 562 + enum: [0, 1, 2, 3] 563 + default: 0 564 + description: | 565 + Specifies the trackpad's ATI mode as follows: 566 + 0: Disabled 567 + 1: Semi-partial 568 + 2: Partial 569 + 3: Full 570 + 571 + azoteq,ati-base: 572 + $ref: /schemas/types.yaml#/definitions/uint32-array 573 + minItems: 6 574 + maxItems: 9 575 + items: 576 + minimum: 45 577 + maximum: 300 578 + default: [45, 45, 45, 45, 45, 45, 45, 45, 45] 579 + description: Specifies each individual trackpad channel's ATI base. 580 + 581 + azoteq,ati-target: 582 + $ref: /schemas/types.yaml#/definitions/uint32 583 + multipleOf: 32 584 + minimum: 0 585 + maximum: 2016 586 + default: 0 587 + description: Specifies the trackpad's ATI target. 588 + 589 + azoteq,cct-increase: 590 + $ref: /schemas/types.yaml#/definitions/uint32 591 + minimum: 0 592 + maximum: 4 593 + default: 0 594 + description: 595 + Specifies the degree to which the trackpad's charge cycle time is to 596 + be increased, with 0 representing no increase. 597 + 598 + azoteq,proj-bias: 599 + $ref: /schemas/types.yaml#/definitions/uint32 600 + enum: [0, 1, 2, 3] 601 + default: 0 602 + description: | 603 + Specifies the bias current applied during projected-capacitance 604 + sensing as follows: 605 + 0: 2.5 uA 606 + 1: 5 uA 607 + 2: 10 uA 608 + 3: 20 uA 609 + 610 + azoteq,sense-freq: 611 + $ref: /schemas/types.yaml#/definitions/uint32 612 + enum: [0, 1, 2, 3] 613 + default: 0 614 + description: | 615 + Specifies the trackpad's sensing frequency as follows (parenthesized 616 + numbers represent the frequency if 'azoteq,clk-div' is present): 617 + 0: 4 MHz (1 MHz) 618 + 1: 2 MHz (500 kHz) 619 + 2: 1 MHz (250 kHz) 620 + 3: 500 kHz (125 kHz) 621 + 622 + azoteq,ati-band-tighten: 623 + type: boolean 624 + description: 625 + Tightens the ATI band from 1/8 to 1/16 of the desired target. 626 + 627 + azoteq,thresh: 628 + $ref: /schemas/types.yaml#/definitions/uint32-array 629 + minItems: 6 630 + maxItems: 9 631 + items: 632 + minimum: 0 633 + maximum: 255 634 + default: [0, 0, 0, 0, 0, 0, 0, 0, 0] 635 + description: 636 + Specifies each individual trackpad channel's touch threshold. 637 + 638 + azoteq,hyst: 639 + $ref: /schemas/types.yaml#/definitions/uint32 640 + minimum: 0 641 + maximum: 15 642 + default: 0 643 + description: Specifies the trackpad's touch hysteresis. 644 + 645 + azoteq,lta-update: 646 + $ref: /schemas/types.yaml#/definitions/uint32 647 + enum: [0, 1, 2, 3, 4, 5, 6, 7] 648 + default: 0 649 + description: | 650 + Specifies the update rate of the trackpad's long-term average during 651 + ultra-low-power mode as follows: 652 + 0: 2 653 + 1: 4 654 + 2: 8 655 + 3: 16 656 + 4: 32 657 + 5: 64 658 + 6: 128 659 + 7: 255 660 + 661 + azoteq,filt-str-trackpad: 662 + $ref: /schemas/types.yaml#/definitions/uint32 663 + enum: [0, 1, 2, 3] 664 + default: 0 665 + description: Specifies the trackpad coordinate filter strength. 666 + 667 + azoteq,filt-str-np-cnt: 668 + $ref: /schemas/types.yaml#/definitions/uint32 669 + enum: [0, 1, 2, 3] 670 + default: 0 671 + description: 672 + Specifies the raw count filter strength during normal-power mode. 673 + 674 + azoteq,filt-str-lp-cnt: 675 + $ref: /schemas/types.yaml#/definitions/uint32 676 + enum: [0, 1, 2, 3] 677 + default: 0 678 + description: 679 + Specifies the raw count filter strength during low-power mode. 680 + 681 + linux,keycodes: 682 + $ref: /schemas/types.yaml#/definitions/uint32-array 683 + minItems: 1 684 + maxItems: 6 685 + description: | 686 + Specifies the numeric keycodes associated with each available gesture 687 + in the following order (enter 0 for unused gestures): 688 + 0: Positive flick or swipe in X direction 689 + 1: Negative flick or swipe in X direction 690 + 2: Positive flick or swipe in Y direction 691 + 3: Negative flick or swipe in Y direction 692 + 4: Tap 693 + 5: Hold 694 + 695 + azoteq,gesture-swipe: 696 + type: boolean 697 + description: 698 + Directs the device to interpret axial gestures as a swipe (finger 699 + remains on trackpad) instead of a flick (finger leaves trackpad). 700 + 701 + azoteq,timeout-tap-ms: 702 + multipleOf: 16 703 + minimum: 0 704 + maximum: 4080 705 + default: 0 706 + description: 707 + Specifies the length of time (in ms) within which a trackpad touch 708 + must be released in order to be interpreted as a tap. 709 + 710 + azoteq,timeout-swipe-ms: 711 + multipleOf: 16 712 + minimum: 0 713 + maximum: 4080 714 + default: 0 715 + description: 716 + Specifies the length of time (in ms) within which an axial gesture 717 + must be completed in order to be interpreted as a flick or swipe. 718 + 719 + azoteq,thresh-swipe: 720 + $ref: /schemas/types.yaml#/definitions/uint32 721 + minimum: 0 722 + maximum: 255 723 + default: 0 724 + description: 725 + Specifies the number of points across which an axial gesture must 726 + travel in order to be interpreted as a flick or swipe. 727 + 728 + dependencies: 729 + azoteq,gesture-swipe: ["linux,keycodes"] 730 + azoteq,timeout-tap-ms: ["linux,keycodes"] 731 + azoteq,timeout-swipe-ms: ["linux,keycodes"] 732 + azoteq,thresh-swipe: ["linux,keycodes"] 733 + 734 + additionalProperties: false 735 + 736 + required: 737 + - compatible 738 + - reg 739 + - interrupts 740 + - "#address-cells" 741 + - "#size-cells" 742 + 743 + additionalProperties: false 744 + 745 + examples: 746 + - | 747 + #include <dt-bindings/input/input.h> 748 + #include <dt-bindings/interrupt-controller/irq.h> 749 + 750 + i2c { 751 + #address-cells = <1>; 752 + #size-cells = <0>; 753 + 754 + iqs626a@44 { 755 + #address-cells = <1>; 756 + #size-cells = <0>; 757 + 758 + compatible = "azoteq,iqs626a"; 759 + reg = <0x44>; 760 + interrupt-parent = <&gpio>; 761 + interrupts = <17 IRQ_TYPE_LEVEL_LOW>; 762 + 763 + azoteq,rate-np-ms = <16>; 764 + azoteq,rate-lp-ms = <160>; 765 + 766 + azoteq,timeout-pwr-ms = <2560>; 767 + azoteq,timeout-lta-ms = <32768>; 768 + 769 + ulp-0 { 770 + azoteq,meas-cap-decrease; 771 + 772 + azoteq,ati-base = <75>; 773 + azoteq,ati-target = <1024>; 774 + 775 + azoteq,rx-enable = <2>, <3>, <4>, 776 + <5>, <6>, <7>; 777 + 778 + event-prox { 779 + linux,code = <KEY_POWER>; 780 + }; 781 + }; 782 + 783 + trackpad-3x3 { 784 + azoteq,filt-str-np-cnt = <1>; 785 + azoteq,filt-str-lp-cnt = <1>; 786 + 787 + azoteq,hyst = <4>; 788 + azoteq,thresh = <35>, <40>, <40>, 789 + <38>, <33>, <38>, 790 + <35>, <35>, <35>; 791 + 792 + azoteq,ati-mode = <3>; 793 + azoteq,ati-base = <195>, <195>, <195>, 794 + <195>, <195>, <195>, 795 + <195>, <195>, <195>; 796 + azoteq,ati-target = <512>; 797 + 798 + azoteq,proj-bias = <1>; 799 + azoteq,sense-freq = <2>; 800 + 801 + linux,keycodes = <KEY_VOLUMEUP>, 802 + <KEY_VOLUMEDOWN>, 803 + <KEY_NEXTSONG>, 804 + <KEY_PREVIOUSSONG>, 805 + <KEY_PLAYPAUSE>, 806 + <KEY_STOPCD>; 807 + 808 + azoteq,gesture-swipe; 809 + azoteq,timeout-swipe-ms = <800>; 810 + azoteq,timeout-tap-ms = <400>; 811 + azoteq,thresh-swipe = <40>; 812 + }; 813 + 814 + /* 815 + * Preserve the default register settings for 816 + * the temperature-tracking channel leveraged 817 + * by reset user interface (RUI) 1. 818 + * 819 + * Scalar properties (e.g. ATI mode) are left 820 + * untouched by simply omitting them; boolean 821 + * properties must be specified explicitly as 822 + * needed. 823 + */ 824 + generic-2 { 825 + azoteq,reseed-disable; 826 + azoteq,meas-cap-decrease; 827 + azoteq,dual-direction; 828 + azoteq,comp-disable; 829 + azoteq,static-enable; 830 + }; 831 + 832 + hall { 833 + azoteq,reseed-disable; 834 + azoteq,meas-cap-decrease; 835 + 836 + event-touch { 837 + linux,code = <SW_LID>; 838 + }; 839 + }; 840 + }; 841 + }; 842 + 843 + ...
+75
Documentation/devicetree/bindings/input/touchscreen/azoteq,iqs5xx.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/input/touchscreen/azoteq,iqs5xx.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Azoteq IQS550/572/525 Trackpad/Touchscreen Controller 8 + 9 + maintainers: 10 + - Jeff LaBundy <jeff@labundy.com> 11 + 12 + description: | 13 + The Azoteq IQS550, IQS572 and IQS525 trackpad and touchscreen controllers 14 + employ projected-capacitance sensing and can track up to five independent 15 + contacts. 16 + 17 + Link to datasheet: https://www.azoteq.com/ 18 + 19 + allOf: 20 + - $ref: touchscreen.yaml# 21 + 22 + properties: 23 + compatible: 24 + enum: 25 + - azoteq,iqs550 26 + - azoteq,iqs572 27 + - azoteq,iqs525 28 + 29 + reg: 30 + maxItems: 1 31 + 32 + interrupts: 33 + maxItems: 1 34 + 35 + reset-gpios: 36 + maxItems: 1 37 + 38 + wakeup-source: true 39 + 40 + touchscreen-size-x: true 41 + touchscreen-size-y: true 42 + touchscreen-inverted-x: true 43 + touchscreen-inverted-y: true 44 + touchscreen-swapped-x-y: true 45 + 46 + required: 47 + - compatible 48 + - reg 49 + - interrupts 50 + 51 + additionalProperties: false 52 + 53 + examples: 54 + - | 55 + #include <dt-bindings/gpio/gpio.h> 56 + #include <dt-bindings/interrupt-controller/irq.h> 57 + 58 + i2c { 59 + #address-cells = <1>; 60 + #size-cells = <0>; 61 + 62 + touchscreen@74 { 63 + compatible = "azoteq,iqs550"; 64 + reg = <0x74>; 65 + interrupt-parent = <&gpio>; 66 + interrupts = <27 IRQ_TYPE_LEVEL_HIGH>; 67 + reset-gpios = <&gpio 22 (GPIO_ACTIVE_LOW | 68 + GPIO_PUSH_PULL)>; 69 + 70 + touchscreen-size-x = <800>; 71 + touchscreen-size-y = <480>; 72 + }; 73 + }; 74 + 75 + ...
+119
Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/input/touchscreen/hycon,hy46xx.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Hycon HY46XX series touchscreen controller bindings 8 + 9 + description: | 10 + There are 6 variants of the chip for various touch panel sizes and cover lens material 11 + Glass: 0.3mm--4.0mm 12 + PET/PMMA: 0.2mm--2.0mm 13 + HY4613(B)-N048 < 6" 14 + HY4614(B)-N068 7" .. 10.1" 15 + HY4621-NS32 < 5" 16 + HY4623-NS48 5.1" .. 7" 17 + Glass: 0.3mm--8.0mm 18 + PET/PMMA: 0.2mm--4.0mm 19 + HY4633(B)-N048 < 6" 20 + HY4635(B)-N048 < 7" .. 10.1" 21 + 22 + maintainers: 23 + - Giulio Benetti <giulio.benetti@benettiengineering.com> 24 + 25 + allOf: 26 + - $ref: touchscreen.yaml# 27 + 28 + properties: 29 + compatible: 30 + enum: 31 + - hycon,hy4613 32 + - hycon,hy4614 33 + - hycon,hy4621 34 + - hycon,hy4623 35 + - hycon,hy4633 36 + - hycon,hy4635 37 + 38 + reg: 39 + maxItems: 1 40 + 41 + interrupts: 42 + maxItems: 1 43 + 44 + reset-gpios: 45 + maxItems: 1 46 + 47 + vcc-supply: true 48 + 49 + hycon,threshold: 50 + description: Allows setting the sensitivity in the range from 0 to 255. 51 + $ref: /schemas/types.yaml#/definitions/uint32 52 + minimum: 0 53 + maximum: 255 54 + 55 + hycon,glove-enable: 56 + type: boolean 57 + description: Allows enabling glove setting. 58 + 59 + hycon,report-speed-hz: 60 + description: Allows setting the report speed in Hertz. 61 + minimum: 1 62 + maximum: 255 63 + 64 + hycon,noise-filter-enable: 65 + type: boolean 66 + description: Allows enabling power noise filter. 67 + 68 + hycon,filter-data: 69 + description: Allows setting how many samples throw before reporting touch 70 + in the range from 0 to 5. 71 + $ref: /schemas/types.yaml#/definitions/uint32 72 + minimum: 0 73 + maximum: 5 74 + 75 + hycon,gain: 76 + description: Allows setting the sensitivity distance in the range from 0 to 5. 77 + $ref: /schemas/types.yaml#/definitions/uint32 78 + minimum: 0 79 + maximum: 5 80 + 81 + hycon,edge-offset: 82 + description: Allows setting the edge compensation in the range from 0 to 16. 83 + $ref: /schemas/types.yaml#/definitions/uint32 84 + minimum: 0 85 + maximum: 16 86 + 87 + touchscreen-size-x: true 88 + touchscreen-size-y: true 89 + touchscreen-fuzz-x: true 90 + touchscreen-fuzz-y: true 91 + touchscreen-inverted-x: true 92 + touchscreen-inverted-y: true 93 + touchscreen-swapped-x-y: true 94 + interrupt-controller: true 95 + 96 + additionalProperties: false 97 + 98 + required: 99 + - compatible 100 + - reg 101 + - interrupts 102 + 103 + examples: 104 + - | 105 + #include <dt-bindings/gpio/gpio.h> 106 + #include <dt-bindings/interrupt-controller/arm-gic.h> 107 + i2c { 108 + #address-cells = <1>; 109 + #size-cells = <0>; 110 + touchscreen@1c { 111 + compatible = "hycon,hy4633"; 112 + reg = <0x1c>; 113 + interrupt-parent = <&gpio2>; 114 + interrupts = <5 IRQ_TYPE_EDGE_FALLING>; 115 + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; 116 + }; 117 + }; 118 + 119 + ...
+73
Documentation/devicetree/bindings/input/touchscreen/ilitek_ts_i2c.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/input/touchscreen/ilitek_ts_i2c.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Ilitek I2C Touchscreen Controller 8 + 9 + maintainers: 10 + - Dmitry Torokhov <dmitry.torokhov@gmail.com> 11 + 12 + allOf: 13 + - $ref: touchscreen.yaml# 14 + 15 + properties: 16 + compatible: 17 + enum: 18 + - ilitek,ili2130 19 + - ilitek,ili2131 20 + - ilitek,ili2132 21 + - ilitek,ili2316 22 + - ilitek,ili2322 23 + - ilitek,ili2323 24 + - ilitek,ili2326 25 + - ilitek,ili2520 26 + - ilitek,ili2521 27 + 28 + reg: 29 + const: 0x41 30 + 31 + interrupts: 32 + maxItems: 1 33 + 34 + reset-gpios: 35 + maxItems: 1 36 + 37 + wakeup-source: 38 + type: boolean 39 + description: touchscreen can be used as a wakeup source. 40 + 41 + touchscreen-size-x: true 42 + touchscreen-size-y: true 43 + touchscreen-inverted-x: true 44 + touchscreen-inverted-y: true 45 + touchscreen-swapped-x-y: true 46 + 47 + additionalProperties: false 48 + 49 + required: 50 + - compatible 51 + - reg 52 + - interrupts 53 + - reset-gpios 54 + 55 + examples: 56 + - | 57 + #include <dt-bindings/interrupt-controller/irq.h> 58 + #include <dt-bindings/gpio/gpio.h> 59 + i2c { 60 + #address-cells = <1>; 61 + #size-cells = <0>; 62 + 63 + touchscreen@41 { 64 + compatible = "ilitek,ili2520"; 65 + reg = <0x41>; 66 + 67 + interrupt-parent = <&gpio1>; 68 + interrupts = <7 IRQ_TYPE_LEVEL_LOW>; 69 + reset-gpios = <&gpio1 8 GPIO_ACTIVE_LOW>; 70 + touchscreen-inverted-y; 71 + wakeup-source; 72 + }; 73 + };
-80
Documentation/devicetree/bindings/input/touchscreen/iqs5xx.txt
··· 1 - Azoteq IQS550/572/525 Trackpad/Touchscreen Controller 2 - 3 - Required properties: 4 - 5 - - compatible : Must be equal to one of the following: 6 - "azoteq,iqs550" 7 - "azoteq,iqs572" 8 - "azoteq,iqs525" 9 - 10 - - reg : I2C slave address for the device. 11 - 12 - - interrupts : GPIO to which the device's active-high RDY 13 - output is connected (see [0]). 14 - 15 - - reset-gpios : GPIO to which the device's active-low NRST 16 - input is connected (see [1]). 17 - 18 - Optional properties: 19 - 20 - - touchscreen-min-x : See [2]. 21 - 22 - - touchscreen-min-y : See [2]. 23 - 24 - - touchscreen-size-x : See [2]. If this property is omitted, the 25 - maximum x-coordinate is specified by the 26 - device's "X Resolution" register. 27 - 28 - - touchscreen-size-y : See [2]. If this property is omitted, the 29 - maximum y-coordinate is specified by the 30 - device's "Y Resolution" register. 31 - 32 - - touchscreen-max-pressure : See [2]. Pressure is expressed as the sum of 33 - the deltas across all channels impacted by a 34 - touch event. A channel's delta is calculated 35 - as its count value minus a reference, where 36 - the count value is inversely proportional to 37 - the channel's capacitance. 38 - 39 - - touchscreen-fuzz-x : See [2]. 40 - 41 - - touchscreen-fuzz-y : See [2]. 42 - 43 - - touchscreen-fuzz-pressure : See [2]. 44 - 45 - - touchscreen-inverted-x : See [2]. Inversion is applied relative to that 46 - which may already be specified by the device's 47 - FLIP_X and FLIP_Y register fields. 48 - 49 - - touchscreen-inverted-y : See [2]. Inversion is applied relative to that 50 - which may already be specified by the device's 51 - FLIP_X and FLIP_Y register fields. 52 - 53 - - touchscreen-swapped-x-y : See [2]. Swapping is applied relative to that 54 - which may already be specified by the device's 55 - SWITCH_XY_AXIS register field. 56 - 57 - [0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt 58 - [1]: Documentation/devicetree/bindings/gpio/gpio.txt 59 - [2]: Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt 60 - 61 - Example: 62 - 63 - &i2c1 { 64 - /* ... */ 65 - 66 - touchscreen@74 { 67 - compatible = "azoteq,iqs550"; 68 - reg = <0x74>; 69 - interrupt-parent = <&gpio>; 70 - interrupts = <17 4>; 71 - reset-gpios = <&gpio 27 1>; 72 - 73 - touchscreen-size-x = <640>; 74 - touchscreen-size-y = <480>; 75 - 76 - touchscreen-max-pressure = <16000>; 77 - }; 78 - 79 - /* ... */ 80 - };
+87
Documentation/devicetree/bindings/input/touchscreen/melfas,mms114.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/input/touchscreen/melfas,mms114.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Melfas MMS114 family touchscreen controller bindings 8 + 9 + maintainers: 10 + - Linus Walleij <linus.walleij@linaro.org> 11 + 12 + allOf: 13 + - $ref: touchscreen.yaml# 14 + 15 + properties: 16 + $nodename: 17 + pattern: "^touchscreen(@.*)?$" 18 + 19 + compatible: 20 + items: 21 + - enum: 22 + - melfas,mms114 23 + - melfas,mms134s 24 + - melfas,mms136 25 + - melfas,mms152 26 + - melfas,mms345l 27 + 28 + reg: 29 + description: I2C address 30 + 31 + clock-frequency: 32 + description: I2C client clock frequency, defined for host 33 + minimum: 100000 34 + maximum: 400000 35 + 36 + interrupts: 37 + maxItems: 1 38 + 39 + avdd-supply: 40 + description: Analog power supply regulator on AVDD pin 41 + 42 + vdd-supply: 43 + description: Digital power supply regulator on VDD pin 44 + 45 + touchscreen-size-x: true 46 + touchscreen-size-y: true 47 + touchscreen-fuzz-x: true 48 + touchscreen-fuzz-y: true 49 + touchscreen-fuzz-pressure: true 50 + touchscreen-inverted-x: true 51 + touchscreen-inverted-y: true 52 + touchscreen-swapped-x-y: true 53 + touchscreen-max-pressure: true 54 + 55 + additionalProperties: false 56 + 57 + required: 58 + - compatible 59 + - reg 60 + - interrupts 61 + - touchscreen-size-x 62 + - touchscreen-size-y 63 + 64 + examples: 65 + - | 66 + #include <dt-bindings/interrupt-controller/irq.h> 67 + i2c { 68 + #address-cells = <1>; 69 + #size-cells = <0>; 70 + touchscreen@48 { 71 + compatible = "melfas,mms114"; 72 + reg = <0x48>; 73 + interrupt-parent = <&gpio>; 74 + interrupts = <39 IRQ_TYPE_EDGE_FALLING>; 75 + avdd-supply = <&ldo1_reg>; 76 + vdd-supply = <&ldo2_reg>; 77 + touchscreen-size-x = <720>; 78 + touchscreen-size-y = <1280>; 79 + touchscreen-fuzz-x = <10>; 80 + touchscreen-fuzz-y = <10>; 81 + touchscreen-fuzz-pressure = <10>; 82 + touchscreen-inverted-x; 83 + touchscreen-inverted-y; 84 + }; 85 + }; 86 + 87 + ...
-42
Documentation/devicetree/bindings/input/touchscreen/mms114.txt
··· 1 - * MELFAS MMS114/MMS152/MMS345L touchscreen controller 2 - 3 - Required properties: 4 - - compatible: should be one of: 5 - - "melfas,mms114" 6 - - "melfas,mms152" 7 - - "melfas,mms345l" 8 - - reg: I2C address of the chip 9 - - interrupts: interrupt to which the chip is connected 10 - - touchscreen-size-x: See [1] 11 - - touchscreen-size-y: See [1] 12 - 13 - Optional properties: 14 - - touchscreen-fuzz-x: See [1] 15 - - touchscreen-fuzz-y: See [1] 16 - - touchscreen-fuzz-pressure: See [1] 17 - - touchscreen-inverted-x: See [1] 18 - - touchscreen-inverted-y: See [1] 19 - - touchscreen-swapped-x-y: See [1] 20 - 21 - [1]: Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt 22 - 23 - Example: 24 - 25 - i2c@00000000 { 26 - /* ... */ 27 - 28 - touchscreen@48 { 29 - compatible = "melfas,mms114"; 30 - reg = <0x48>; 31 - interrupts = <39 0>; 32 - touchscreen-size-x = <720>; 33 - touchscreen-size-y = <1280>; 34 - touchscreen-fuzz-x = <10>; 35 - touchscreen-fuzz-y = <10>; 36 - touchscreen-fuzz-pressure = <10>; 37 - touchscreen-inverted-x; 38 - touchscreen-inverted-y; 39 - }; 40 - 41 - /* ... */ 42 - };
+69
Documentation/devicetree/bindings/input/touchscreen/mstar,msg2638.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/input/touchscreen/mstar,msg2638.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: MStar msg2638 touchscreen controller Bindings 8 + 9 + maintainers: 10 + - Vincent Knecht <vincent.knecht@mailoo.org> 11 + 12 + allOf: 13 + - $ref: touchscreen.yaml# 14 + 15 + properties: 16 + compatible: 17 + const: mstar,msg2638 18 + 19 + reg: 20 + const: 0x26 21 + 22 + interrupts: 23 + maxItems: 1 24 + 25 + reset-gpios: 26 + maxItems: 1 27 + 28 + vdd-supply: 29 + description: Power supply regulator for the chip 30 + 31 + vddio-supply: 32 + description: Power supply regulator for the I2C bus 33 + 34 + touchscreen-size-x: true 35 + touchscreen-size-y: true 36 + 37 + additionalProperties: false 38 + 39 + required: 40 + - compatible 41 + - reg 42 + - interrupts 43 + - reset-gpios 44 + - touchscreen-size-x 45 + - touchscreen-size-y 46 + 47 + examples: 48 + - | 49 + #include <dt-bindings/gpio/gpio.h> 50 + #include <dt-bindings/interrupt-controller/irq.h> 51 + i2c { 52 + #address-cells = <1>; 53 + #size-cells = <0>; 54 + touchscreen@26 { 55 + compatible = "mstar,msg2638"; 56 + reg = <0x26>; 57 + interrupt-parent = <&msmgpio>; 58 + interrupts = <13 IRQ_TYPE_EDGE_FALLING>; 59 + reset-gpios = <&msmgpio 100 GPIO_ACTIVE_LOW>; 60 + pinctrl-names = "default"; 61 + pinctrl-0 = <&ts_int_reset_default>; 62 + vdd-supply = <&pm8916_l17>; 63 + vddio-supply = <&pm8916_l5>; 64 + touchscreen-size-x = <2048>; 65 + touchscreen-size-y = <2048>; 66 + }; 67 + }; 68 + 69 + ...
+2
Documentation/devicetree/bindings/vendor-prefixes.yaml
··· 495 495 description: Shenzhen Hugsun Technology Co. Ltd. 496 496 "^hwacom,.*": 497 497 description: HwaCom Systems Inc. 498 + "^hycon,.*": 499 + description: Hycon Technology Corp. 498 500 "^hydis,.*": 499 501 description: Hydis Technologies 500 502 "^hyundai,.*":
+6 -2
Documentation/input/devices/rotary-encoder.rst
··· 107 107 }, 108 108 }; 109 109 110 - static const struct property_entry rotary_encoder_properties[] __initconst = { 110 + static const struct property_entry rotary_encoder_properties[] = { 111 111 PROPERTY_ENTRY_U32("rotary-encoder,steps-per-period", 24), 112 112 PROPERTY_ENTRY_U32("linux,axis", ABS_X), 113 113 PROPERTY_ENTRY_U32("rotary-encoder,relative_axis", 0), 114 114 { }, 115 + }; 116 + 117 + static const struct software_node rotary_encoder_node = { 118 + .properties = rotary_encoder_properties, 115 119 }; 116 120 117 121 static struct platform_device rotary_encoder_device = { ··· 126 122 ... 127 123 128 124 gpiod_add_lookup_table(&rotary_encoder_gpios); 129 - device_add_properties(&rotary_encoder_device, rotary_encoder_properties); 125 + device_add_software_node(&rotary_encoder_device.dev, &rotary_encoder_node); 130 126 platform_device_register(&rotary_encoder_device); 131 127 132 128 ...
+7
MAINTAINERS
··· 8388 8388 F: mm/hwpoison-inject.c 8389 8389 F: mm/memory-failure.c 8390 8390 8391 + HYCON HY46XX TOUCHSCREEN SUPPORT 8392 + M: Giulio Benetti <giulio.benetti@benettiengineering.com> 8393 + L: linux-input@vger.kernel.org 8394 + S: Maintained 8395 + F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml 8396 + F: drivers/input/touchscreen/hycon-hy46xx.c 8397 + 8391 8398 HYGON PROCESSOR SUPPORT 8392 8399 M: Pu Wen <puwen@hygon.cn> 8393 8400 L: linux-kernel@vger.kernel.org
+1
drivers/input/Makefile
··· 7 7 8 8 obj-$(CONFIG_INPUT) += input-core.o 9 9 input-core-y := input.o input-compat.o input-mt.o input-poller.o ff-core.o 10 + input-core-y += touchscreen.o 10 11 11 12 obj-$(CONFIG_INPUT_FF_MEMLESS) += ff-memless.o 12 13 obj-$(CONFIG_INPUT_SPARSEKMAP) += sparse-keymap.o
+2
drivers/input/joystick/xpad.c
··· 268 268 { 0x1689, 0xfd00, "Razer Onza Tournament Edition", 0, XTYPE_XBOX360 }, 269 269 { 0x1689, 0xfd01, "Razer Onza Classic Edition", 0, XTYPE_XBOX360 }, 270 270 { 0x1689, 0xfe00, "Razer Sabertooth", 0, XTYPE_XBOX360 }, 271 + { 0x1949, 0x041a, "Amazon Game Controller", 0, XTYPE_XBOX360 }, 271 272 { 0x1bad, 0x0002, "Harmonix Rock Band Guitar", 0, XTYPE_XBOX360 }, 272 273 { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, 273 274 { 0x1bad, 0x0130, "Ion Drum Rocker", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, ··· 441 440 XPAD_XBOX360_VENDOR(0x15e4), /* Numark X-Box 360 controllers */ 442 441 XPAD_XBOX360_VENDOR(0x162e), /* Joytech X-Box 360 controllers */ 443 442 XPAD_XBOX360_VENDOR(0x1689), /* Razer Onza */ 443 + XPAD_XBOX360_VENDOR(0x1949), /* Amazon controllers */ 444 444 XPAD_XBOX360_VENDOR(0x1bad), /* Harminix Rock Band Guitar and Drums */ 445 445 XPAD_XBOX360_VENDOR(0x20d6), /* PowerA Controllers */ 446 446 XPAD_XBOXONE_VENDOR(0x20d6), /* PowerA Controllers */
+72 -33
drivers/input/keyboard/gpio_keys.c
··· 8 8 9 9 #include <linux/module.h> 10 10 11 + #include <linux/hrtimer.h> 11 12 #include <linux/init.h> 12 13 #include <linux/fs.h> 13 14 #include <linux/interrupt.h> ··· 37 36 38 37 unsigned short *code; 39 38 40 - struct timer_list release_timer; 39 + struct hrtimer release_timer; 41 40 unsigned int release_delay; /* in msecs, for IRQ-only buttons */ 42 41 43 42 struct delayed_work work; 43 + struct hrtimer debounce_timer; 44 44 unsigned int software_debounce; /* in msecs, for GPIO-driven buttons */ 45 45 46 46 unsigned int irq; ··· 50 48 bool disabled; 51 49 bool key_pressed; 52 50 bool suspended; 51 + bool debounce_use_hrtimer; 53 52 }; 54 53 55 54 struct gpio_keys_drvdata { ··· 125 122 return (type == EV_KEY) ? dev->keybit : dev->swbit; 126 123 } 127 124 125 + static void gpio_keys_quiesce_key(void *data) 126 + { 127 + struct gpio_button_data *bdata = data; 128 + 129 + if (!bdata->gpiod) 130 + hrtimer_cancel(&bdata->release_timer); 131 + if (bdata->debounce_use_hrtimer) 132 + hrtimer_cancel(&bdata->debounce_timer); 133 + else 134 + cancel_delayed_work_sync(&bdata->work); 135 + } 136 + 128 137 /** 129 138 * gpio_keys_disable_button() - disables given GPIO button 130 139 * @bdata: button data for button to be disabled ··· 157 142 * Disable IRQ and associated timer/work structure. 158 143 */ 159 144 disable_irq(bdata->irq); 160 - 161 - if (bdata->gpiod) 162 - cancel_delayed_work_sync(&bdata->work); 163 - else 164 - del_timer_sync(&bdata->release_timer); 165 - 145 + gpio_keys_quiesce_key(bdata); 166 146 bdata->disabled = true; 167 147 } 168 148 } ··· 370 360 unsigned int type = button->type ?: EV_KEY; 371 361 int state; 372 362 373 - state = gpiod_get_value_cansleep(bdata->gpiod); 363 + state = bdata->debounce_use_hrtimer ? 364 + gpiod_get_value(bdata->gpiod) : 365 + gpiod_get_value_cansleep(bdata->gpiod); 374 366 if (state < 0) { 375 367 dev_err(input->dev.parent, 376 368 "failed to get gpio state: %d\n", state); ··· 385 373 } else { 386 374 input_event(input, type, *bdata->code, state); 387 375 } 388 - input_sync(input); 376 + } 377 + 378 + static void gpio_keys_debounce_event(struct gpio_button_data *bdata) 379 + { 380 + gpio_keys_gpio_report_event(bdata); 381 + input_sync(bdata->input); 382 + 383 + if (bdata->button->wakeup) 384 + pm_relax(bdata->input->dev.parent); 389 385 } 390 386 391 387 static void gpio_keys_gpio_work_func(struct work_struct *work) ··· 401 381 struct gpio_button_data *bdata = 402 382 container_of(work, struct gpio_button_data, work.work); 403 383 404 - gpio_keys_gpio_report_event(bdata); 384 + gpio_keys_debounce_event(bdata); 385 + } 405 386 406 - if (bdata->button->wakeup) 407 - pm_relax(bdata->input->dev.parent); 387 + static enum hrtimer_restart gpio_keys_debounce_timer(struct hrtimer *t) 388 + { 389 + struct gpio_button_data *bdata = 390 + container_of(t, struct gpio_button_data, debounce_timer); 391 + 392 + gpio_keys_debounce_event(bdata); 393 + 394 + return HRTIMER_NORESTART; 408 395 } 409 396 410 397 static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id) ··· 435 408 } 436 409 } 437 410 438 - mod_delayed_work(system_wq, 439 - &bdata->work, 440 - msecs_to_jiffies(bdata->software_debounce)); 411 + if (bdata->debounce_use_hrtimer) { 412 + hrtimer_start(&bdata->debounce_timer, 413 + ms_to_ktime(bdata->software_debounce), 414 + HRTIMER_MODE_REL); 415 + } else { 416 + mod_delayed_work(system_wq, 417 + &bdata->work, 418 + msecs_to_jiffies(bdata->software_debounce)); 419 + } 441 420 442 421 return IRQ_HANDLED; 443 422 } 444 423 445 - static void gpio_keys_irq_timer(struct timer_list *t) 424 + static enum hrtimer_restart gpio_keys_irq_timer(struct hrtimer *t) 446 425 { 447 - struct gpio_button_data *bdata = from_timer(bdata, t, release_timer); 426 + struct gpio_button_data *bdata = container_of(t, 427 + struct gpio_button_data, 428 + release_timer); 448 429 struct input_dev *input = bdata->input; 449 - unsigned long flags; 450 430 451 - spin_lock_irqsave(&bdata->lock, flags); 452 431 if (bdata->key_pressed) { 453 432 input_event(input, EV_KEY, *bdata->code, 0); 454 433 input_sync(input); 455 434 bdata->key_pressed = false; 456 435 } 457 - spin_unlock_irqrestore(&bdata->lock, flags); 436 + 437 + return HRTIMER_NORESTART; 458 438 } 459 439 460 440 static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id) ··· 491 457 } 492 458 493 459 if (bdata->release_delay) 494 - mod_timer(&bdata->release_timer, 495 - jiffies + msecs_to_jiffies(bdata->release_delay)); 460 + hrtimer_start(&bdata->release_timer, 461 + ms_to_ktime(bdata->release_delay), 462 + HRTIMER_MODE_REL_HARD); 496 463 out: 497 464 spin_unlock_irqrestore(&bdata->lock, flags); 498 465 return IRQ_HANDLED; 499 - } 500 - 501 - static void gpio_keys_quiesce_key(void *data) 502 - { 503 - struct gpio_button_data *bdata = data; 504 - 505 - if (bdata->gpiod) 506 - cancel_delayed_work_sync(&bdata->work); 507 - else 508 - del_timer_sync(&bdata->release_timer); 509 466 } 510 467 511 468 static int gpio_keys_setup_key(struct platform_device *pdev, ··· 568 543 if (error < 0) 569 544 bdata->software_debounce = 570 545 button->debounce_interval; 546 + 547 + /* 548 + * If reading the GPIO won't sleep, we can use a 549 + * hrtimer instead of a standard timer for the software 550 + * debounce, to reduce the latency as much as possible. 551 + */ 552 + bdata->debounce_use_hrtimer = 553 + !gpiod_cansleep(bdata->gpiod); 571 554 } 572 555 573 556 if (button->irq) { ··· 593 560 } 594 561 595 562 INIT_DELAYED_WORK(&bdata->work, gpio_keys_gpio_work_func); 563 + 564 + hrtimer_init(&bdata->debounce_timer, 565 + CLOCK_REALTIME, HRTIMER_MODE_REL); 566 + bdata->debounce_timer.function = gpio_keys_debounce_timer; 596 567 597 568 isr = gpio_keys_gpio_isr; 598 569 irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING; ··· 632 595 } 633 596 634 597 bdata->release_delay = button->debounce_interval; 635 - timer_setup(&bdata->release_timer, gpio_keys_irq_timer, 0); 598 + hrtimer_init(&bdata->release_timer, 599 + CLOCK_REALTIME, HRTIMER_MODE_REL_HARD); 600 + bdata->release_timer.function = gpio_keys_irq_timer; 636 601 637 602 isr = gpio_keys_irq_isr; 638 603 irqflags = 0;
+2 -11
drivers/input/keyboard/imx_keypad.c
··· 408 408 return -EIO; 409 409 } 410 410 411 - #ifdef CONFIG_OF 412 411 static const struct of_device_id imx_keypad_of_match[] = { 413 412 { .compatible = "fsl,imx21-kpp", }, 414 413 { /* sentinel */ } 415 414 }; 416 415 MODULE_DEVICE_TABLE(of, imx_keypad_of_match); 417 - #endif 418 416 419 417 static int imx_keypad_probe(struct platform_device *pdev) 420 418 { 421 - const struct matrix_keymap_data *keymap_data = 422 - dev_get_platdata(&pdev->dev); 423 419 struct imx_keypad *keypad; 424 420 struct input_dev *input_dev; 425 421 int irq, error, i, row, col; 426 - 427 - if (!keymap_data && !pdev->dev.of_node) { 428 - dev_err(&pdev->dev, "no keymap defined\n"); 429 - return -EINVAL; 430 - } 431 422 432 423 irq = platform_get_irq(pdev, 0); 433 424 if (irq < 0) ··· 460 469 input_dev->open = imx_keypad_open; 461 470 input_dev->close = imx_keypad_close; 462 471 463 - error = matrix_keypad_build_keymap(keymap_data, NULL, 472 + error = matrix_keypad_build_keymap(NULL, NULL, 464 473 MAX_MATRIX_KEY_ROWS, 465 474 MAX_MATRIX_KEY_COLS, 466 475 keypad->keycodes, input_dev); ··· 573 582 .driver = { 574 583 .name = "imx-keypad", 575 584 .pm = &imx_kbd_pm_ops, 576 - .of_match_table = of_match_ptr(imx_keypad_of_match), 585 + .of_match_table = imx_keypad_of_match, 577 586 }, 578 587 .probe = imx_keypad_probe, 579 588 };
+1 -2
drivers/input/keyboard/tca6416-keypad.c
··· 274 274 error = request_threaded_irq(chip->irqnum, NULL, 275 275 tca6416_keys_isr, 276 276 IRQF_TRIGGER_FALLING | 277 - IRQF_ONESHOT, 277 + IRQF_ONESHOT | IRQF_NO_AUTOEN, 278 278 "tca6416-keypad", chip); 279 279 if (error) { 280 280 dev_dbg(&client->dev, ··· 282 282 chip->irqnum, error); 283 283 goto fail1; 284 284 } 285 - disable_irq(chip->irqnum); 286 285 } 287 286 288 287 error = input_register_device(input);
+2 -3
drivers/input/keyboard/tegra-kbc.c
··· 694 694 input_set_drvdata(kbc->idev, kbc); 695 695 696 696 err = devm_request_irq(&pdev->dev, kbc->irq, tegra_kbc_isr, 697 - IRQF_TRIGGER_HIGH, pdev->name, kbc); 697 + IRQF_TRIGGER_HIGH | IRQF_NO_AUTOEN, 698 + pdev->name, kbc); 698 699 if (err) { 699 700 dev_err(&pdev->dev, "failed to request keyboard IRQ\n"); 700 701 return err; 701 702 } 702 - 703 - disable_irq(kbc->irq); 704 703 705 704 err = input_register_device(kbc->idev); 706 705 if (err) {
+11
drivers/input/misc/Kconfig
··· 763 763 To compile this driver as a module, choose M here: the 764 764 module will be called iqs269a. 765 765 766 + config INPUT_IQS626A 767 + tristate "Azoteq IQS626A capacitive touch controller" 768 + depends on I2C 769 + select REGMAP_I2C 770 + help 771 + Say Y to enable support for the Azoteq IQS626A capacitive 772 + touch controller. 773 + 774 + To compile this driver as a module, choose M here: the 775 + module will be called iqs626a. 776 + 766 777 config INPUT_CMA3000 767 778 tristate "VTI CMA3000 Tri-axis accelerometer" 768 779 help
+1
drivers/input/misc/Makefile
··· 43 43 obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o 44 44 obj-$(CONFIG_INPUT_IMS_PCU) += ims-pcu.o 45 45 obj-$(CONFIG_INPUT_IQS269A) += iqs269a.o 46 + obj-$(CONFIG_INPUT_IQS626A) += iqs626a.o 46 47 obj-$(CONFIG_INPUT_IXP4XX_BEEPER) += ixp4xx-beeper.o 47 48 obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) += keyspan_remote.o 48 49 obj-$(CONFIG_INPUT_KXTJ9) += kxtj9.o
-1
drivers/input/misc/ims-pcu.c
··· 2018 2018 } 2019 2019 2020 2020 usb_set_intfdata(pcu->ctrl_intf, pcu); 2021 - usb_set_intfdata(pcu->data_intf, pcu); 2022 2021 2023 2022 error = ims_pcu_buffers_alloc(pcu); 2024 2023 if (error)
+1838
drivers/input/misc/iqs626a.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * Azoteq IQS626A Capacitive Touch Controller 4 + * 5 + * Copyright (C) 2020 Jeff LaBundy <jeff@labundy.com> 6 + * 7 + * This driver registers up to 2 input devices: one representing capacitive or 8 + * inductive keys as well as Hall-effect switches, and one for a trackpad that 9 + * can express various gestures. 10 + */ 11 + 12 + #include <linux/bits.h> 13 + #include <linux/completion.h> 14 + #include <linux/delay.h> 15 + #include <linux/device.h> 16 + #include <linux/err.h> 17 + #include <linux/i2c.h> 18 + #include <linux/input.h> 19 + #include <linux/input/touchscreen.h> 20 + #include <linux/interrupt.h> 21 + #include <linux/kernel.h> 22 + #include <linux/module.h> 23 + #include <linux/of_device.h> 24 + #include <linux/property.h> 25 + #include <linux/regmap.h> 26 + #include <linux/slab.h> 27 + 28 + #define IQS626_VER_INFO 0x00 29 + #define IQS626_VER_INFO_PROD_NUM 0x51 30 + 31 + #define IQS626_SYS_FLAGS 0x02 32 + #define IQS626_SYS_FLAGS_SHOW_RESET BIT(15) 33 + #define IQS626_SYS_FLAGS_IN_ATI BIT(12) 34 + #define IQS626_SYS_FLAGS_PWR_MODE_MASK GENMASK(9, 8) 35 + #define IQS626_SYS_FLAGS_PWR_MODE_SHIFT 8 36 + 37 + #define IQS626_HALL_OUTPUT 0x23 38 + 39 + #define IQS626_SYS_SETTINGS 0x80 40 + #define IQS626_SYS_SETTINGS_CLK_DIV BIT(15) 41 + #define IQS626_SYS_SETTINGS_ULP_AUTO BIT(14) 42 + #define IQS626_SYS_SETTINGS_DIS_AUTO BIT(13) 43 + #define IQS626_SYS_SETTINGS_PWR_MODE_MASK GENMASK(12, 11) 44 + #define IQS626_SYS_SETTINGS_PWR_MODE_SHIFT 11 45 + #define IQS626_SYS_SETTINGS_PWR_MODE_MAX 3 46 + #define IQS626_SYS_SETTINGS_ULP_UPDATE_MASK GENMASK(10, 8) 47 + #define IQS626_SYS_SETTINGS_ULP_UPDATE_SHIFT 8 48 + #define IQS626_SYS_SETTINGS_ULP_UPDATE_MAX 7 49 + #define IQS626_SYS_SETTINGS_EVENT_MODE BIT(5) 50 + #define IQS626_SYS_SETTINGS_EVENT_MODE_LP BIT(4) 51 + #define IQS626_SYS_SETTINGS_REDO_ATI BIT(2) 52 + #define IQS626_SYS_SETTINGS_ACK_RESET BIT(0) 53 + 54 + #define IQS626_MISC_A_ATI_BAND_DISABLE BIT(7) 55 + #define IQS626_MISC_A_TPx_LTA_UPDATE_MASK GENMASK(6, 4) 56 + #define IQS626_MISC_A_TPx_LTA_UPDATE_SHIFT 4 57 + #define IQS626_MISC_A_TPx_LTA_UPDATE_MAX 7 58 + #define IQS626_MISC_A_ATI_LP_ONLY BIT(3) 59 + #define IQS626_MISC_A_GPIO3_SELECT_MASK GENMASK(2, 0) 60 + #define IQS626_MISC_A_GPIO3_SELECT_MAX 7 61 + 62 + #define IQS626_EVENT_MASK_SYS BIT(6) 63 + #define IQS626_EVENT_MASK_GESTURE BIT(3) 64 + #define IQS626_EVENT_MASK_DEEP BIT(2) 65 + #define IQS626_EVENT_MASK_TOUCH BIT(1) 66 + #define IQS626_EVENT_MASK_PROX BIT(0) 67 + 68 + #define IQS626_RATE_NP_MS_MAX 255 69 + #define IQS626_RATE_LP_MS_MAX 255 70 + #define IQS626_RATE_ULP_MS_MAX 4080 71 + #define IQS626_TIMEOUT_PWR_MS_MAX 130560 72 + #define IQS626_TIMEOUT_LTA_MS_MAX 130560 73 + 74 + #define IQS626_MISC_B_RESEED_UI_SEL_MASK GENMASK(7, 6) 75 + #define IQS626_MISC_B_RESEED_UI_SEL_SHIFT 6 76 + #define IQS626_MISC_B_RESEED_UI_SEL_MAX 3 77 + #define IQS626_MISC_B_THRESH_EXTEND BIT(5) 78 + #define IQS626_MISC_B_TRACKING_UI_ENABLE BIT(4) 79 + #define IQS626_MISC_B_TPx_SWIPE BIT(3) 80 + #define IQS626_MISC_B_RESEED_OFFSET BIT(2) 81 + #define IQS626_MISC_B_FILT_STR_TPx GENMASK(1, 0) 82 + 83 + #define IQS626_THRESH_SWIPE_MAX 255 84 + #define IQS626_TIMEOUT_TAP_MS_MAX 4080 85 + #define IQS626_TIMEOUT_SWIPE_MS_MAX 4080 86 + 87 + #define IQS626_CHx_ENG_0_MEAS_CAP_SIZE BIT(7) 88 + #define IQS626_CHx_ENG_0_RX_TERM_VSS BIT(5) 89 + #define IQS626_CHx_ENG_0_LINEARIZE BIT(4) 90 + #define IQS626_CHx_ENG_0_DUAL_DIR BIT(3) 91 + #define IQS626_CHx_ENG_0_FILT_DISABLE BIT(2) 92 + #define IQS626_CHx_ENG_0_ATI_MODE_MASK GENMASK(1, 0) 93 + #define IQS626_CHx_ENG_0_ATI_MODE_MAX 3 94 + 95 + #define IQS626_CHx_ENG_1_CCT_HIGH_1 BIT(7) 96 + #define IQS626_CHx_ENG_1_CCT_HIGH_0 BIT(6) 97 + #define IQS626_CHx_ENG_1_PROJ_BIAS_MASK GENMASK(5, 4) 98 + #define IQS626_CHx_ENG_1_PROJ_BIAS_SHIFT 4 99 + #define IQS626_CHx_ENG_1_PROJ_BIAS_MAX 3 100 + #define IQS626_CHx_ENG_1_CCT_ENABLE BIT(3) 101 + #define IQS626_CHx_ENG_1_SENSE_FREQ_MASK GENMASK(2, 1) 102 + #define IQS626_CHx_ENG_1_SENSE_FREQ_SHIFT 1 103 + #define IQS626_CHx_ENG_1_SENSE_FREQ_MAX 3 104 + #define IQS626_CHx_ENG_1_ATI_BAND_TIGHTEN BIT(0) 105 + 106 + #define IQS626_CHx_ENG_2_LOCAL_CAP_MASK GENMASK(7, 6) 107 + #define IQS626_CHx_ENG_2_LOCAL_CAP_SHIFT 6 108 + #define IQS626_CHx_ENG_2_LOCAL_CAP_MAX 3 109 + #define IQS626_CHx_ENG_2_LOCAL_CAP_ENABLE BIT(5) 110 + #define IQS626_CHx_ENG_2_SENSE_MODE_MASK GENMASK(3, 0) 111 + #define IQS626_CHx_ENG_2_SENSE_MODE_MAX 15 112 + 113 + #define IQS626_CHx_ENG_3_TX_FREQ_MASK GENMASK(5, 4) 114 + #define IQS626_CHx_ENG_3_TX_FREQ_SHIFT 4 115 + #define IQS626_CHx_ENG_3_TX_FREQ_MAX 3 116 + #define IQS626_CHx_ENG_3_INV_LOGIC BIT(0) 117 + 118 + #define IQS626_CHx_ENG_4_RX_TERM_VREG BIT(6) 119 + #define IQS626_CHx_ENG_4_CCT_LOW_1 BIT(5) 120 + #define IQS626_CHx_ENG_4_CCT_LOW_0 BIT(4) 121 + #define IQS626_CHx_ENG_4_COMP_DISABLE BIT(1) 122 + #define IQS626_CHx_ENG_4_STATIC_ENABLE BIT(0) 123 + 124 + #define IQS626_TPx_ATI_BASE_MIN 45 125 + #define IQS626_TPx_ATI_BASE_MAX 300 126 + #define IQS626_CHx_ATI_BASE_MASK GENMASK(7, 6) 127 + #define IQS626_CHx_ATI_BASE_75 0x00 128 + #define IQS626_CHx_ATI_BASE_100 0x40 129 + #define IQS626_CHx_ATI_BASE_150 0x80 130 + #define IQS626_CHx_ATI_BASE_200 0xC0 131 + #define IQS626_CHx_ATI_TARGET_MASK GENMASK(5, 0) 132 + #define IQS626_CHx_ATI_TARGET_MAX 2016 133 + 134 + #define IQS626_CHx_THRESH_MAX 255 135 + #define IQS626_CHx_HYST_DEEP_MASK GENMASK(7, 4) 136 + #define IQS626_CHx_HYST_DEEP_SHIFT 4 137 + #define IQS626_CHx_HYST_TOUCH_MASK GENMASK(3, 0) 138 + #define IQS626_CHx_HYST_MAX 15 139 + 140 + #define IQS626_FILT_STR_NP_TPx_MASK GENMASK(7, 6) 141 + #define IQS626_FILT_STR_NP_TPx_SHIFT 6 142 + #define IQS626_FILT_STR_LP_TPx_MASK GENMASK(5, 4) 143 + #define IQS626_FILT_STR_LP_TPx_SHIFT 4 144 + 145 + #define IQS626_FILT_STR_NP_CNT_MASK GENMASK(7, 6) 146 + #define IQS626_FILT_STR_NP_CNT_SHIFT 6 147 + #define IQS626_FILT_STR_LP_CNT_MASK GENMASK(5, 4) 148 + #define IQS626_FILT_STR_LP_CNT_SHIFT 4 149 + #define IQS626_FILT_STR_NP_LTA_MASK GENMASK(3, 2) 150 + #define IQS626_FILT_STR_NP_LTA_SHIFT 2 151 + #define IQS626_FILT_STR_LP_LTA_MASK GENMASK(1, 0) 152 + #define IQS626_FILT_STR_MAX 3 153 + 154 + #define IQS626_ULP_PROJ_ENABLE BIT(4) 155 + #define IQS626_GEN_WEIGHT_MAX 255 156 + 157 + #define IQS626_MAX_REG 0xFF 158 + 159 + #define IQS626_NUM_CH_TP_3 9 160 + #define IQS626_NUM_CH_TP_2 6 161 + #define IQS626_NUM_CH_GEN 3 162 + #define IQS626_NUM_CRx_TX 8 163 + 164 + #define IQS626_PWR_MODE_POLL_SLEEP_US 50000 165 + #define IQS626_PWR_MODE_POLL_TIMEOUT_US 500000 166 + 167 + #define iqs626_irq_wait() usleep_range(350, 400) 168 + 169 + enum iqs626_ch_id { 170 + IQS626_CH_ULP_0, 171 + IQS626_CH_TP_2, 172 + IQS626_CH_TP_3, 173 + IQS626_CH_GEN_0, 174 + IQS626_CH_GEN_1, 175 + IQS626_CH_GEN_2, 176 + IQS626_CH_HALL, 177 + }; 178 + 179 + enum iqs626_rx_inactive { 180 + IQS626_RX_INACTIVE_VSS, 181 + IQS626_RX_INACTIVE_FLOAT, 182 + IQS626_RX_INACTIVE_VREG, 183 + }; 184 + 185 + enum iqs626_st_offs { 186 + IQS626_ST_OFFS_PROX, 187 + IQS626_ST_OFFS_DIR, 188 + IQS626_ST_OFFS_TOUCH, 189 + IQS626_ST_OFFS_DEEP, 190 + }; 191 + 192 + enum iqs626_th_offs { 193 + IQS626_TH_OFFS_PROX, 194 + IQS626_TH_OFFS_TOUCH, 195 + IQS626_TH_OFFS_DEEP, 196 + }; 197 + 198 + enum iqs626_event_id { 199 + IQS626_EVENT_PROX_DN, 200 + IQS626_EVENT_PROX_UP, 201 + IQS626_EVENT_TOUCH_DN, 202 + IQS626_EVENT_TOUCH_UP, 203 + IQS626_EVENT_DEEP_DN, 204 + IQS626_EVENT_DEEP_UP, 205 + }; 206 + 207 + enum iqs626_gesture_id { 208 + IQS626_GESTURE_FLICK_X_POS, 209 + IQS626_GESTURE_FLICK_X_NEG, 210 + IQS626_GESTURE_FLICK_Y_POS, 211 + IQS626_GESTURE_FLICK_Y_NEG, 212 + IQS626_GESTURE_TAP, 213 + IQS626_GESTURE_HOLD, 214 + IQS626_NUM_GESTURES, 215 + }; 216 + 217 + struct iqs626_event_desc { 218 + const char *name; 219 + enum iqs626_st_offs st_offs; 220 + enum iqs626_th_offs th_offs; 221 + bool dir_up; 222 + u8 mask; 223 + }; 224 + 225 + static const struct iqs626_event_desc iqs626_events[] = { 226 + [IQS626_EVENT_PROX_DN] = { 227 + .name = "event-prox", 228 + .st_offs = IQS626_ST_OFFS_PROX, 229 + .th_offs = IQS626_TH_OFFS_PROX, 230 + .mask = IQS626_EVENT_MASK_PROX, 231 + }, 232 + [IQS626_EVENT_PROX_UP] = { 233 + .name = "event-prox-alt", 234 + .st_offs = IQS626_ST_OFFS_PROX, 235 + .th_offs = IQS626_TH_OFFS_PROX, 236 + .dir_up = true, 237 + .mask = IQS626_EVENT_MASK_PROX, 238 + }, 239 + [IQS626_EVENT_TOUCH_DN] = { 240 + .name = "event-touch", 241 + .st_offs = IQS626_ST_OFFS_TOUCH, 242 + .th_offs = IQS626_TH_OFFS_TOUCH, 243 + .mask = IQS626_EVENT_MASK_TOUCH, 244 + }, 245 + [IQS626_EVENT_TOUCH_UP] = { 246 + .name = "event-touch-alt", 247 + .st_offs = IQS626_ST_OFFS_TOUCH, 248 + .th_offs = IQS626_TH_OFFS_TOUCH, 249 + .dir_up = true, 250 + .mask = IQS626_EVENT_MASK_TOUCH, 251 + }, 252 + [IQS626_EVENT_DEEP_DN] = { 253 + .name = "event-deep", 254 + .st_offs = IQS626_ST_OFFS_DEEP, 255 + .th_offs = IQS626_TH_OFFS_DEEP, 256 + .mask = IQS626_EVENT_MASK_DEEP, 257 + }, 258 + [IQS626_EVENT_DEEP_UP] = { 259 + .name = "event-deep-alt", 260 + .st_offs = IQS626_ST_OFFS_DEEP, 261 + .th_offs = IQS626_TH_OFFS_DEEP, 262 + .dir_up = true, 263 + .mask = IQS626_EVENT_MASK_DEEP, 264 + }, 265 + }; 266 + 267 + struct iqs626_ver_info { 268 + u8 prod_num; 269 + u8 sw_num; 270 + u8 hw_num; 271 + u8 padding; 272 + } __packed; 273 + 274 + struct iqs626_flags { 275 + __be16 system; 276 + u8 gesture; 277 + u8 padding_a; 278 + u8 states[4]; 279 + u8 ref_active; 280 + u8 padding_b; 281 + u8 comp_min; 282 + u8 comp_max; 283 + u8 trackpad_x; 284 + u8 trackpad_y; 285 + } __packed; 286 + 287 + struct iqs626_ch_reg_ulp { 288 + u8 thresh[2]; 289 + u8 hyst; 290 + u8 filter; 291 + u8 engine[2]; 292 + u8 ati_target; 293 + u8 padding; 294 + __be16 ati_comp; 295 + u8 rx_enable; 296 + u8 tx_enable; 297 + } __packed; 298 + 299 + struct iqs626_ch_reg_tp { 300 + u8 thresh; 301 + u8 ati_base; 302 + __be16 ati_comp; 303 + } __packed; 304 + 305 + struct iqs626_tp_grp_reg { 306 + u8 hyst; 307 + u8 ati_target; 308 + u8 engine[2]; 309 + struct iqs626_ch_reg_tp ch_reg_tp[IQS626_NUM_CH_TP_3]; 310 + } __packed; 311 + 312 + struct iqs626_ch_reg_gen { 313 + u8 thresh[3]; 314 + u8 padding; 315 + u8 hyst; 316 + u8 ati_target; 317 + __be16 ati_comp; 318 + u8 engine[5]; 319 + u8 filter; 320 + u8 rx_enable; 321 + u8 tx_enable; 322 + u8 assoc_select; 323 + u8 assoc_weight; 324 + } __packed; 325 + 326 + struct iqs626_ch_reg_hall { 327 + u8 engine; 328 + u8 thresh; 329 + u8 hyst; 330 + u8 ati_target; 331 + __be16 ati_comp; 332 + } __packed; 333 + 334 + struct iqs626_sys_reg { 335 + __be16 general; 336 + u8 misc_a; 337 + u8 event_mask; 338 + u8 active; 339 + u8 reseed; 340 + u8 rate_np; 341 + u8 rate_lp; 342 + u8 rate_ulp; 343 + u8 timeout_pwr; 344 + u8 timeout_rdy; 345 + u8 timeout_lta; 346 + u8 misc_b; 347 + u8 thresh_swipe; 348 + u8 timeout_tap; 349 + u8 timeout_swipe; 350 + u8 redo_ati; 351 + u8 padding; 352 + struct iqs626_ch_reg_ulp ch_reg_ulp; 353 + struct iqs626_tp_grp_reg tp_grp_reg; 354 + struct iqs626_ch_reg_gen ch_reg_gen[IQS626_NUM_CH_GEN]; 355 + struct iqs626_ch_reg_hall ch_reg_hall; 356 + } __packed; 357 + 358 + struct iqs626_channel_desc { 359 + const char *name; 360 + int num_ch; 361 + u8 active; 362 + bool events[ARRAY_SIZE(iqs626_events)]; 363 + }; 364 + 365 + static const struct iqs626_channel_desc iqs626_channels[] = { 366 + [IQS626_CH_ULP_0] = { 367 + .name = "ulp-0", 368 + .num_ch = 1, 369 + .active = BIT(0), 370 + .events = { 371 + [IQS626_EVENT_PROX_DN] = true, 372 + [IQS626_EVENT_PROX_UP] = true, 373 + [IQS626_EVENT_TOUCH_DN] = true, 374 + [IQS626_EVENT_TOUCH_UP] = true, 375 + }, 376 + }, 377 + [IQS626_CH_TP_2] = { 378 + .name = "trackpad-3x2", 379 + .num_ch = IQS626_NUM_CH_TP_2, 380 + .active = BIT(1), 381 + .events = { 382 + [IQS626_EVENT_TOUCH_DN] = true, 383 + }, 384 + }, 385 + [IQS626_CH_TP_3] = { 386 + .name = "trackpad-3x3", 387 + .num_ch = IQS626_NUM_CH_TP_3, 388 + .active = BIT(2) | BIT(1), 389 + .events = { 390 + [IQS626_EVENT_TOUCH_DN] = true, 391 + }, 392 + }, 393 + [IQS626_CH_GEN_0] = { 394 + .name = "generic-0", 395 + .num_ch = 1, 396 + .active = BIT(4), 397 + .events = { 398 + [IQS626_EVENT_PROX_DN] = true, 399 + [IQS626_EVENT_PROX_UP] = true, 400 + [IQS626_EVENT_TOUCH_DN] = true, 401 + [IQS626_EVENT_TOUCH_UP] = true, 402 + [IQS626_EVENT_DEEP_DN] = true, 403 + [IQS626_EVENT_DEEP_UP] = true, 404 + }, 405 + }, 406 + [IQS626_CH_GEN_1] = { 407 + .name = "generic-1", 408 + .num_ch = 1, 409 + .active = BIT(5), 410 + .events = { 411 + [IQS626_EVENT_PROX_DN] = true, 412 + [IQS626_EVENT_PROX_UP] = true, 413 + [IQS626_EVENT_TOUCH_DN] = true, 414 + [IQS626_EVENT_TOUCH_UP] = true, 415 + [IQS626_EVENT_DEEP_DN] = true, 416 + [IQS626_EVENT_DEEP_UP] = true, 417 + }, 418 + }, 419 + [IQS626_CH_GEN_2] = { 420 + .name = "generic-2", 421 + .num_ch = 1, 422 + .active = BIT(6), 423 + .events = { 424 + [IQS626_EVENT_PROX_DN] = true, 425 + [IQS626_EVENT_PROX_UP] = true, 426 + [IQS626_EVENT_TOUCH_DN] = true, 427 + [IQS626_EVENT_TOUCH_UP] = true, 428 + [IQS626_EVENT_DEEP_DN] = true, 429 + [IQS626_EVENT_DEEP_UP] = true, 430 + }, 431 + }, 432 + [IQS626_CH_HALL] = { 433 + .name = "hall", 434 + .num_ch = 1, 435 + .active = BIT(7), 436 + .events = { 437 + [IQS626_EVENT_TOUCH_DN] = true, 438 + [IQS626_EVENT_TOUCH_UP] = true, 439 + }, 440 + }, 441 + }; 442 + 443 + struct iqs626_private { 444 + struct i2c_client *client; 445 + struct regmap *regmap; 446 + struct iqs626_sys_reg sys_reg; 447 + struct completion ati_done; 448 + struct input_dev *keypad; 449 + struct input_dev *trackpad; 450 + struct touchscreen_properties prop; 451 + unsigned int kp_type[ARRAY_SIZE(iqs626_channels)] 452 + [ARRAY_SIZE(iqs626_events)]; 453 + unsigned int kp_code[ARRAY_SIZE(iqs626_channels)] 454 + [ARRAY_SIZE(iqs626_events)]; 455 + unsigned int tp_code[IQS626_NUM_GESTURES]; 456 + unsigned int suspend_mode; 457 + }; 458 + 459 + static int iqs626_parse_events(struct iqs626_private *iqs626, 460 + const struct fwnode_handle *ch_node, 461 + enum iqs626_ch_id ch_id) 462 + { 463 + struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg; 464 + struct i2c_client *client = iqs626->client; 465 + const struct fwnode_handle *ev_node; 466 + const char *ev_name; 467 + u8 *thresh, *hyst; 468 + unsigned int thresh_tp[IQS626_NUM_CH_TP_3]; 469 + unsigned int val; 470 + int num_ch = iqs626_channels[ch_id].num_ch; 471 + int error, i, j; 472 + 473 + switch (ch_id) { 474 + case IQS626_CH_ULP_0: 475 + thresh = sys_reg->ch_reg_ulp.thresh; 476 + hyst = &sys_reg->ch_reg_ulp.hyst; 477 + break; 478 + 479 + case IQS626_CH_TP_2: 480 + case IQS626_CH_TP_3: 481 + thresh = &sys_reg->tp_grp_reg.ch_reg_tp[0].thresh; 482 + hyst = &sys_reg->tp_grp_reg.hyst; 483 + break; 484 + 485 + case IQS626_CH_GEN_0: 486 + case IQS626_CH_GEN_1: 487 + case IQS626_CH_GEN_2: 488 + i = ch_id - IQS626_CH_GEN_0; 489 + thresh = sys_reg->ch_reg_gen[i].thresh; 490 + hyst = &sys_reg->ch_reg_gen[i].hyst; 491 + break; 492 + 493 + case IQS626_CH_HALL: 494 + thresh = &sys_reg->ch_reg_hall.thresh; 495 + hyst = &sys_reg->ch_reg_hall.hyst; 496 + break; 497 + 498 + default: 499 + return -EINVAL; 500 + } 501 + 502 + for (i = 0; i < ARRAY_SIZE(iqs626_events); i++) { 503 + if (!iqs626_channels[ch_id].events[i]) 504 + continue; 505 + 506 + if (ch_id == IQS626_CH_TP_2 || ch_id == IQS626_CH_TP_3) { 507 + /* 508 + * Trackpad touch events are simply described under the 509 + * trackpad child node. 510 + */ 511 + ev_node = ch_node; 512 + } else { 513 + ev_name = iqs626_events[i].name; 514 + ev_node = fwnode_get_named_child_node(ch_node, ev_name); 515 + if (!ev_node) 516 + continue; 517 + 518 + if (!fwnode_property_read_u32(ev_node, "linux,code", 519 + &val)) { 520 + iqs626->kp_code[ch_id][i] = val; 521 + 522 + if (fwnode_property_read_u32(ev_node, 523 + "linux,input-type", 524 + &val)) { 525 + if (ch_id == IQS626_CH_HALL) 526 + val = EV_SW; 527 + else 528 + val = EV_KEY; 529 + } 530 + 531 + if (val != EV_KEY && val != EV_SW) { 532 + dev_err(&client->dev, 533 + "Invalid input type: %u\n", 534 + val); 535 + return -EINVAL; 536 + } 537 + 538 + iqs626->kp_type[ch_id][i] = val; 539 + 540 + sys_reg->event_mask &= ~iqs626_events[i].mask; 541 + } 542 + } 543 + 544 + if (!fwnode_property_read_u32(ev_node, "azoteq,hyst", &val)) { 545 + if (val > IQS626_CHx_HYST_MAX) { 546 + dev_err(&client->dev, 547 + "Invalid %s channel hysteresis: %u\n", 548 + fwnode_get_name(ch_node), val); 549 + return -EINVAL; 550 + } 551 + 552 + if (i == IQS626_EVENT_DEEP_DN || 553 + i == IQS626_EVENT_DEEP_UP) { 554 + *hyst &= ~IQS626_CHx_HYST_DEEP_MASK; 555 + *hyst |= (val << IQS626_CHx_HYST_DEEP_SHIFT); 556 + } else if (i == IQS626_EVENT_TOUCH_DN || 557 + i == IQS626_EVENT_TOUCH_UP) { 558 + *hyst &= ~IQS626_CHx_HYST_TOUCH_MASK; 559 + *hyst |= val; 560 + } 561 + } 562 + 563 + if (ch_id != IQS626_CH_TP_2 && ch_id != IQS626_CH_TP_3 && 564 + !fwnode_property_read_u32(ev_node, "azoteq,thresh", &val)) { 565 + if (val > IQS626_CHx_THRESH_MAX) { 566 + dev_err(&client->dev, 567 + "Invalid %s channel threshold: %u\n", 568 + fwnode_get_name(ch_node), val); 569 + return -EINVAL; 570 + } 571 + 572 + if (ch_id == IQS626_CH_HALL) 573 + *thresh = val; 574 + else 575 + *(thresh + iqs626_events[i].th_offs) = val; 576 + 577 + continue; 578 + } 579 + 580 + if (!fwnode_property_present(ev_node, "azoteq,thresh")) 581 + continue; 582 + 583 + error = fwnode_property_read_u32_array(ev_node, "azoteq,thresh", 584 + thresh_tp, num_ch); 585 + if (error) { 586 + dev_err(&client->dev, 587 + "Failed to read %s channel thresholds: %d\n", 588 + fwnode_get_name(ch_node), error); 589 + return error; 590 + } 591 + 592 + for (j = 0; j < num_ch; j++) { 593 + if (thresh_tp[j] > IQS626_CHx_THRESH_MAX) { 594 + dev_err(&client->dev, 595 + "Invalid %s channel threshold: %u\n", 596 + fwnode_get_name(ch_node), thresh_tp[j]); 597 + return -EINVAL; 598 + } 599 + 600 + sys_reg->tp_grp_reg.ch_reg_tp[j].thresh = thresh_tp[j]; 601 + } 602 + } 603 + 604 + return 0; 605 + } 606 + 607 + static int iqs626_parse_ati_target(struct iqs626_private *iqs626, 608 + const struct fwnode_handle *ch_node, 609 + enum iqs626_ch_id ch_id) 610 + { 611 + struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg; 612 + struct i2c_client *client = iqs626->client; 613 + unsigned int ati_base[IQS626_NUM_CH_TP_3]; 614 + unsigned int val; 615 + u8 *ati_target; 616 + int num_ch = iqs626_channels[ch_id].num_ch; 617 + int error, i; 618 + 619 + switch (ch_id) { 620 + case IQS626_CH_ULP_0: 621 + ati_target = &sys_reg->ch_reg_ulp.ati_target; 622 + break; 623 + 624 + case IQS626_CH_TP_2: 625 + case IQS626_CH_TP_3: 626 + ati_target = &sys_reg->tp_grp_reg.ati_target; 627 + break; 628 + 629 + case IQS626_CH_GEN_0: 630 + case IQS626_CH_GEN_1: 631 + case IQS626_CH_GEN_2: 632 + i = ch_id - IQS626_CH_GEN_0; 633 + ati_target = &sys_reg->ch_reg_gen[i].ati_target; 634 + break; 635 + 636 + case IQS626_CH_HALL: 637 + ati_target = &sys_reg->ch_reg_hall.ati_target; 638 + break; 639 + 640 + default: 641 + return -EINVAL; 642 + } 643 + 644 + if (!fwnode_property_read_u32(ch_node, "azoteq,ati-target", &val)) { 645 + if (val > IQS626_CHx_ATI_TARGET_MAX) { 646 + dev_err(&client->dev, 647 + "Invalid %s channel ATI target: %u\n", 648 + fwnode_get_name(ch_node), val); 649 + return -EINVAL; 650 + } 651 + 652 + *ati_target &= ~IQS626_CHx_ATI_TARGET_MASK; 653 + *ati_target |= (val / 32); 654 + } 655 + 656 + if (ch_id != IQS626_CH_TP_2 && ch_id != IQS626_CH_TP_3 && 657 + !fwnode_property_read_u32(ch_node, "azoteq,ati-base", &val)) { 658 + switch (val) { 659 + case 75: 660 + val = IQS626_CHx_ATI_BASE_75; 661 + break; 662 + 663 + case 100: 664 + val = IQS626_CHx_ATI_BASE_100; 665 + break; 666 + 667 + case 150: 668 + val = IQS626_CHx_ATI_BASE_150; 669 + break; 670 + 671 + case 200: 672 + val = IQS626_CHx_ATI_BASE_200; 673 + break; 674 + 675 + default: 676 + dev_err(&client->dev, 677 + "Invalid %s channel ATI base: %u\n", 678 + fwnode_get_name(ch_node), val); 679 + return -EINVAL; 680 + } 681 + 682 + *ati_target &= ~IQS626_CHx_ATI_BASE_MASK; 683 + *ati_target |= val; 684 + 685 + return 0; 686 + } 687 + 688 + if (!fwnode_property_present(ch_node, "azoteq,ati-base")) 689 + return 0; 690 + 691 + error = fwnode_property_read_u32_array(ch_node, "azoteq,ati-base", 692 + ati_base, num_ch); 693 + if (error) { 694 + dev_err(&client->dev, 695 + "Failed to read %s channel ATI bases: %d\n", 696 + fwnode_get_name(ch_node), error); 697 + return error; 698 + } 699 + 700 + for (i = 0; i < num_ch; i++) { 701 + if (ati_base[i] < IQS626_TPx_ATI_BASE_MIN || 702 + ati_base[i] > IQS626_TPx_ATI_BASE_MAX) { 703 + dev_err(&client->dev, 704 + "Invalid %s channel ATI base: %u\n", 705 + fwnode_get_name(ch_node), ati_base[i]); 706 + return -EINVAL; 707 + } 708 + 709 + ati_base[i] -= IQS626_TPx_ATI_BASE_MIN; 710 + sys_reg->tp_grp_reg.ch_reg_tp[i].ati_base = ati_base[i]; 711 + } 712 + 713 + return 0; 714 + } 715 + 716 + static int iqs626_parse_pins(struct iqs626_private *iqs626, 717 + const struct fwnode_handle *ch_node, 718 + const char *propname, u8 *enable) 719 + { 720 + struct i2c_client *client = iqs626->client; 721 + unsigned int val[IQS626_NUM_CRx_TX]; 722 + int error, count, i; 723 + 724 + if (!fwnode_property_present(ch_node, propname)) 725 + return 0; 726 + 727 + count = fwnode_property_count_u32(ch_node, propname); 728 + if (count > IQS626_NUM_CRx_TX) { 729 + dev_err(&client->dev, 730 + "Too many %s channel CRX/TX pins present\n", 731 + fwnode_get_name(ch_node)); 732 + return -EINVAL; 733 + } else if (count < 0) { 734 + dev_err(&client->dev, 735 + "Failed to count %s channel CRX/TX pins: %d\n", 736 + fwnode_get_name(ch_node), count); 737 + return count; 738 + } 739 + 740 + error = fwnode_property_read_u32_array(ch_node, propname, val, count); 741 + if (error) { 742 + dev_err(&client->dev, 743 + "Failed to read %s channel CRX/TX pins: %d\n", 744 + fwnode_get_name(ch_node), error); 745 + return error; 746 + } 747 + 748 + *enable = 0; 749 + 750 + for (i = 0; i < count; i++) { 751 + if (val[i] >= IQS626_NUM_CRx_TX) { 752 + dev_err(&client->dev, 753 + "Invalid %s channel CRX/TX pin: %u\n", 754 + fwnode_get_name(ch_node), val[i]); 755 + return -EINVAL; 756 + } 757 + 758 + *enable |= BIT(val[i]); 759 + } 760 + 761 + return 0; 762 + } 763 + 764 + static int iqs626_parse_trackpad(struct iqs626_private *iqs626, 765 + const struct fwnode_handle *ch_node) 766 + { 767 + struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg; 768 + struct i2c_client *client = iqs626->client; 769 + u8 *hyst = &sys_reg->tp_grp_reg.hyst; 770 + unsigned int val; 771 + int error, count; 772 + 773 + if (!fwnode_property_read_u32(ch_node, "azoteq,lta-update", &val)) { 774 + if (val > IQS626_MISC_A_TPx_LTA_UPDATE_MAX) { 775 + dev_err(&client->dev, 776 + "Invalid %s channel update rate: %u\n", 777 + fwnode_get_name(ch_node), val); 778 + return -EINVAL; 779 + } 780 + 781 + sys_reg->misc_a &= ~IQS626_MISC_A_TPx_LTA_UPDATE_MASK; 782 + sys_reg->misc_a |= (val << IQS626_MISC_A_TPx_LTA_UPDATE_SHIFT); 783 + } 784 + 785 + if (!fwnode_property_read_u32(ch_node, "azoteq,filt-str-trackpad", 786 + &val)) { 787 + if (val > IQS626_FILT_STR_MAX) { 788 + dev_err(&client->dev, 789 + "Invalid %s channel filter strength: %u\n", 790 + fwnode_get_name(ch_node), val); 791 + return -EINVAL; 792 + } 793 + 794 + sys_reg->misc_b &= ~IQS626_MISC_B_FILT_STR_TPx; 795 + sys_reg->misc_b |= val; 796 + } 797 + 798 + if (!fwnode_property_read_u32(ch_node, "azoteq,filt-str-np-cnt", 799 + &val)) { 800 + if (val > IQS626_FILT_STR_MAX) { 801 + dev_err(&client->dev, 802 + "Invalid %s channel filter strength: %u\n", 803 + fwnode_get_name(ch_node), val); 804 + return -EINVAL; 805 + } 806 + 807 + *hyst &= ~IQS626_FILT_STR_NP_TPx_MASK; 808 + *hyst |= (val << IQS626_FILT_STR_NP_TPx_SHIFT); 809 + } 810 + 811 + if (!fwnode_property_read_u32(ch_node, "azoteq,filt-str-lp-cnt", 812 + &val)) { 813 + if (val > IQS626_FILT_STR_MAX) { 814 + dev_err(&client->dev, 815 + "Invalid %s channel filter strength: %u\n", 816 + fwnode_get_name(ch_node), val); 817 + return -EINVAL; 818 + } 819 + 820 + *hyst &= ~IQS626_FILT_STR_LP_TPx_MASK; 821 + *hyst |= (val << IQS626_FILT_STR_LP_TPx_SHIFT); 822 + } 823 + 824 + if (!fwnode_property_present(ch_node, "linux,keycodes")) 825 + return 0; 826 + 827 + count = fwnode_property_count_u32(ch_node, "linux,keycodes"); 828 + if (count > IQS626_NUM_GESTURES) { 829 + dev_err(&client->dev, "Too many keycodes present\n"); 830 + return -EINVAL; 831 + } else if (count < 0) { 832 + dev_err(&client->dev, "Failed to count keycodes: %d\n", count); 833 + return count; 834 + } 835 + 836 + error = fwnode_property_read_u32_array(ch_node, "linux,keycodes", 837 + iqs626->tp_code, count); 838 + if (error) { 839 + dev_err(&client->dev, "Failed to read keycodes: %d\n", error); 840 + return error; 841 + } 842 + 843 + sys_reg->misc_b &= ~IQS626_MISC_B_TPx_SWIPE; 844 + if (fwnode_property_present(ch_node, "azoteq,gesture-swipe")) 845 + sys_reg->misc_b |= IQS626_MISC_B_TPx_SWIPE; 846 + 847 + if (!fwnode_property_read_u32(ch_node, "azoteq,timeout-tap-ms", 848 + &val)) { 849 + if (val > IQS626_TIMEOUT_TAP_MS_MAX) { 850 + dev_err(&client->dev, 851 + "Invalid %s channel timeout: %u\n", 852 + fwnode_get_name(ch_node), val); 853 + return -EINVAL; 854 + } 855 + 856 + sys_reg->timeout_tap = val / 16; 857 + } 858 + 859 + if (!fwnode_property_read_u32(ch_node, "azoteq,timeout-swipe-ms", 860 + &val)) { 861 + if (val > IQS626_TIMEOUT_SWIPE_MS_MAX) { 862 + dev_err(&client->dev, 863 + "Invalid %s channel timeout: %u\n", 864 + fwnode_get_name(ch_node), val); 865 + return -EINVAL; 866 + } 867 + 868 + sys_reg->timeout_swipe = val / 16; 869 + } 870 + 871 + if (!fwnode_property_read_u32(ch_node, "azoteq,thresh-swipe", 872 + &val)) { 873 + if (val > IQS626_THRESH_SWIPE_MAX) { 874 + dev_err(&client->dev, 875 + "Invalid %s channel threshold: %u\n", 876 + fwnode_get_name(ch_node), val); 877 + return -EINVAL; 878 + } 879 + 880 + sys_reg->thresh_swipe = val; 881 + } 882 + 883 + sys_reg->event_mask &= ~IQS626_EVENT_MASK_GESTURE; 884 + 885 + return 0; 886 + } 887 + 888 + static int iqs626_parse_channel(struct iqs626_private *iqs626, 889 + const struct fwnode_handle *ch_node, 890 + enum iqs626_ch_id ch_id) 891 + { 892 + struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg; 893 + struct i2c_client *client = iqs626->client; 894 + u8 *engine, *filter, *rx_enable, *tx_enable; 895 + u8 *assoc_select, *assoc_weight; 896 + unsigned int val; 897 + int error, i; 898 + 899 + switch (ch_id) { 900 + case IQS626_CH_ULP_0: 901 + engine = sys_reg->ch_reg_ulp.engine; 902 + break; 903 + 904 + case IQS626_CH_TP_2: 905 + case IQS626_CH_TP_3: 906 + engine = sys_reg->tp_grp_reg.engine; 907 + break; 908 + 909 + case IQS626_CH_GEN_0: 910 + case IQS626_CH_GEN_1: 911 + case IQS626_CH_GEN_2: 912 + i = ch_id - IQS626_CH_GEN_0; 913 + engine = sys_reg->ch_reg_gen[i].engine; 914 + break; 915 + 916 + case IQS626_CH_HALL: 917 + engine = &sys_reg->ch_reg_hall.engine; 918 + break; 919 + 920 + default: 921 + return -EINVAL; 922 + } 923 + 924 + *engine |= IQS626_CHx_ENG_0_MEAS_CAP_SIZE; 925 + if (fwnode_property_present(ch_node, "azoteq,meas-cap-decrease")) 926 + *engine &= ~IQS626_CHx_ENG_0_MEAS_CAP_SIZE; 927 + 928 + *engine |= IQS626_CHx_ENG_0_RX_TERM_VSS; 929 + if (!fwnode_property_read_u32(ch_node, "azoteq,rx-inactive", &val)) { 930 + switch (val) { 931 + case IQS626_RX_INACTIVE_VSS: 932 + break; 933 + 934 + case IQS626_RX_INACTIVE_FLOAT: 935 + *engine &= ~IQS626_CHx_ENG_0_RX_TERM_VSS; 936 + if (ch_id == IQS626_CH_GEN_0 || 937 + ch_id == IQS626_CH_GEN_1 || 938 + ch_id == IQS626_CH_GEN_2) 939 + *(engine + 4) &= ~IQS626_CHx_ENG_4_RX_TERM_VREG; 940 + break; 941 + 942 + case IQS626_RX_INACTIVE_VREG: 943 + if (ch_id == IQS626_CH_GEN_0 || 944 + ch_id == IQS626_CH_GEN_1 || 945 + ch_id == IQS626_CH_GEN_2) { 946 + *engine &= ~IQS626_CHx_ENG_0_RX_TERM_VSS; 947 + *(engine + 4) |= IQS626_CHx_ENG_4_RX_TERM_VREG; 948 + break; 949 + } 950 + fallthrough; 951 + 952 + default: 953 + dev_err(&client->dev, 954 + "Invalid %s channel CRX pin termination: %u\n", 955 + fwnode_get_name(ch_node), val); 956 + return -EINVAL; 957 + } 958 + } 959 + 960 + *engine &= ~IQS626_CHx_ENG_0_LINEARIZE; 961 + if (fwnode_property_present(ch_node, "azoteq,linearize")) 962 + *engine |= IQS626_CHx_ENG_0_LINEARIZE; 963 + 964 + *engine &= ~IQS626_CHx_ENG_0_DUAL_DIR; 965 + if (fwnode_property_present(ch_node, "azoteq,dual-direction")) 966 + *engine |= IQS626_CHx_ENG_0_DUAL_DIR; 967 + 968 + *engine &= ~IQS626_CHx_ENG_0_FILT_DISABLE; 969 + if (fwnode_property_present(ch_node, "azoteq,filt-disable")) 970 + *engine |= IQS626_CHx_ENG_0_FILT_DISABLE; 971 + 972 + if (!fwnode_property_read_u32(ch_node, "azoteq,ati-mode", &val)) { 973 + if (val > IQS626_CHx_ENG_0_ATI_MODE_MAX) { 974 + dev_err(&client->dev, 975 + "Invalid %s channel ATI mode: %u\n", 976 + fwnode_get_name(ch_node), val); 977 + return -EINVAL; 978 + } 979 + 980 + *engine &= ~IQS626_CHx_ENG_0_ATI_MODE_MASK; 981 + *engine |= val; 982 + } 983 + 984 + if (ch_id == IQS626_CH_HALL) 985 + return 0; 986 + 987 + *(engine + 1) &= ~IQS626_CHx_ENG_1_CCT_ENABLE; 988 + if (!fwnode_property_read_u32(ch_node, "azoteq,cct-increase", 989 + &val) && val) { 990 + unsigned int orig_val = val--; 991 + 992 + /* 993 + * In the case of the generic channels, the charge cycle time 994 + * field doubles in size and straddles two separate registers. 995 + */ 996 + if (ch_id == IQS626_CH_GEN_0 || 997 + ch_id == IQS626_CH_GEN_1 || 998 + ch_id == IQS626_CH_GEN_2) { 999 + *(engine + 4) &= ~IQS626_CHx_ENG_4_CCT_LOW_1; 1000 + if (val & BIT(1)) 1001 + *(engine + 4) |= IQS626_CHx_ENG_4_CCT_LOW_1; 1002 + 1003 + *(engine + 4) &= ~IQS626_CHx_ENG_4_CCT_LOW_0; 1004 + if (val & BIT(0)) 1005 + *(engine + 4) |= IQS626_CHx_ENG_4_CCT_LOW_0; 1006 + 1007 + val >>= 2; 1008 + } 1009 + 1010 + if (val & ~GENMASK(1, 0)) { 1011 + dev_err(&client->dev, 1012 + "Invalid %s channel charge cycle time: %u\n", 1013 + fwnode_get_name(ch_node), orig_val); 1014 + return -EINVAL; 1015 + } 1016 + 1017 + *(engine + 1) &= ~IQS626_CHx_ENG_1_CCT_HIGH_1; 1018 + if (val & BIT(1)) 1019 + *(engine + 1) |= IQS626_CHx_ENG_1_CCT_HIGH_1; 1020 + 1021 + *(engine + 1) &= ~IQS626_CHx_ENG_1_CCT_HIGH_0; 1022 + if (val & BIT(0)) 1023 + *(engine + 1) |= IQS626_CHx_ENG_1_CCT_HIGH_0; 1024 + 1025 + *(engine + 1) |= IQS626_CHx_ENG_1_CCT_ENABLE; 1026 + } 1027 + 1028 + if (!fwnode_property_read_u32(ch_node, "azoteq,proj-bias", &val)) { 1029 + if (val > IQS626_CHx_ENG_1_PROJ_BIAS_MAX) { 1030 + dev_err(&client->dev, 1031 + "Invalid %s channel bias current: %u\n", 1032 + fwnode_get_name(ch_node), val); 1033 + return -EINVAL; 1034 + } 1035 + 1036 + *(engine + 1) &= ~IQS626_CHx_ENG_1_PROJ_BIAS_MASK; 1037 + *(engine + 1) |= (val << IQS626_CHx_ENG_1_PROJ_BIAS_SHIFT); 1038 + } 1039 + 1040 + if (!fwnode_property_read_u32(ch_node, "azoteq,sense-freq", &val)) { 1041 + if (val > IQS626_CHx_ENG_1_SENSE_FREQ_MAX) { 1042 + dev_err(&client->dev, 1043 + "Invalid %s channel sensing frequency: %u\n", 1044 + fwnode_get_name(ch_node), val); 1045 + return -EINVAL; 1046 + } 1047 + 1048 + *(engine + 1) &= ~IQS626_CHx_ENG_1_SENSE_FREQ_MASK; 1049 + *(engine + 1) |= (val << IQS626_CHx_ENG_1_SENSE_FREQ_SHIFT); 1050 + } 1051 + 1052 + *(engine + 1) &= ~IQS626_CHx_ENG_1_ATI_BAND_TIGHTEN; 1053 + if (fwnode_property_present(ch_node, "azoteq,ati-band-tighten")) 1054 + *(engine + 1) |= IQS626_CHx_ENG_1_ATI_BAND_TIGHTEN; 1055 + 1056 + if (ch_id == IQS626_CH_TP_2 || ch_id == IQS626_CH_TP_3) 1057 + return iqs626_parse_trackpad(iqs626, ch_node); 1058 + 1059 + if (ch_id == IQS626_CH_ULP_0) { 1060 + sys_reg->ch_reg_ulp.hyst &= ~IQS626_ULP_PROJ_ENABLE; 1061 + if (fwnode_property_present(ch_node, "azoteq,proj-enable")) 1062 + sys_reg->ch_reg_ulp.hyst |= IQS626_ULP_PROJ_ENABLE; 1063 + 1064 + filter = &sys_reg->ch_reg_ulp.filter; 1065 + 1066 + rx_enable = &sys_reg->ch_reg_ulp.rx_enable; 1067 + tx_enable = &sys_reg->ch_reg_ulp.tx_enable; 1068 + } else { 1069 + i = ch_id - IQS626_CH_GEN_0; 1070 + filter = &sys_reg->ch_reg_gen[i].filter; 1071 + 1072 + rx_enable = &sys_reg->ch_reg_gen[i].rx_enable; 1073 + tx_enable = &sys_reg->ch_reg_gen[i].tx_enable; 1074 + } 1075 + 1076 + if (!fwnode_property_read_u32(ch_node, "azoteq,filt-str-np-cnt", 1077 + &val)) { 1078 + if (val > IQS626_FILT_STR_MAX) { 1079 + dev_err(&client->dev, 1080 + "Invalid %s channel filter strength: %u\n", 1081 + fwnode_get_name(ch_node), val); 1082 + return -EINVAL; 1083 + } 1084 + 1085 + *filter &= ~IQS626_FILT_STR_NP_CNT_MASK; 1086 + *filter |= (val << IQS626_FILT_STR_NP_CNT_SHIFT); 1087 + } 1088 + 1089 + if (!fwnode_property_read_u32(ch_node, "azoteq,filt-str-lp-cnt", 1090 + &val)) { 1091 + if (val > IQS626_FILT_STR_MAX) { 1092 + dev_err(&client->dev, 1093 + "Invalid %s channel filter strength: %u\n", 1094 + fwnode_get_name(ch_node), val); 1095 + return -EINVAL; 1096 + } 1097 + 1098 + *filter &= ~IQS626_FILT_STR_LP_CNT_MASK; 1099 + *filter |= (val << IQS626_FILT_STR_LP_CNT_SHIFT); 1100 + } 1101 + 1102 + if (!fwnode_property_read_u32(ch_node, "azoteq,filt-str-np-lta", 1103 + &val)) { 1104 + if (val > IQS626_FILT_STR_MAX) { 1105 + dev_err(&client->dev, 1106 + "Invalid %s channel filter strength: %u\n", 1107 + fwnode_get_name(ch_node), val); 1108 + return -EINVAL; 1109 + } 1110 + 1111 + *filter &= ~IQS626_FILT_STR_NP_LTA_MASK; 1112 + *filter |= (val << IQS626_FILT_STR_NP_LTA_SHIFT); 1113 + } 1114 + 1115 + if (!fwnode_property_read_u32(ch_node, "azoteq,filt-str-lp-lta", 1116 + &val)) { 1117 + if (val > IQS626_FILT_STR_MAX) { 1118 + dev_err(&client->dev, 1119 + "Invalid %s channel filter strength: %u\n", 1120 + fwnode_get_name(ch_node), val); 1121 + return -EINVAL; 1122 + } 1123 + 1124 + *filter &= ~IQS626_FILT_STR_LP_LTA_MASK; 1125 + *filter |= val; 1126 + } 1127 + 1128 + error = iqs626_parse_pins(iqs626, ch_node, "azoteq,rx-enable", 1129 + rx_enable); 1130 + if (error) 1131 + return error; 1132 + 1133 + error = iqs626_parse_pins(iqs626, ch_node, "azoteq,tx-enable", 1134 + tx_enable); 1135 + if (error) 1136 + return error; 1137 + 1138 + if (ch_id == IQS626_CH_ULP_0) 1139 + return 0; 1140 + 1141 + *(engine + 2) &= ~IQS626_CHx_ENG_2_LOCAL_CAP_ENABLE; 1142 + if (!fwnode_property_read_u32(ch_node, "azoteq,local-cap-size", 1143 + &val) && val) { 1144 + unsigned int orig_val = val--; 1145 + 1146 + if (val > IQS626_CHx_ENG_2_LOCAL_CAP_MAX) { 1147 + dev_err(&client->dev, 1148 + "Invalid %s channel local cap. size: %u\n", 1149 + fwnode_get_name(ch_node), orig_val); 1150 + return -EINVAL; 1151 + } 1152 + 1153 + *(engine + 2) &= ~IQS626_CHx_ENG_2_LOCAL_CAP_MASK; 1154 + *(engine + 2) |= (val << IQS626_CHx_ENG_2_LOCAL_CAP_SHIFT); 1155 + 1156 + *(engine + 2) |= IQS626_CHx_ENG_2_LOCAL_CAP_ENABLE; 1157 + } 1158 + 1159 + if (!fwnode_property_read_u32(ch_node, "azoteq,sense-mode", &val)) { 1160 + if (val > IQS626_CHx_ENG_2_SENSE_MODE_MAX) { 1161 + dev_err(&client->dev, 1162 + "Invalid %s channel sensing mode: %u\n", 1163 + fwnode_get_name(ch_node), val); 1164 + return -EINVAL; 1165 + } 1166 + 1167 + *(engine + 2) &= ~IQS626_CHx_ENG_2_SENSE_MODE_MASK; 1168 + *(engine + 2) |= val; 1169 + } 1170 + 1171 + if (!fwnode_property_read_u32(ch_node, "azoteq,tx-freq", &val)) { 1172 + if (val > IQS626_CHx_ENG_3_TX_FREQ_MAX) { 1173 + dev_err(&client->dev, 1174 + "Invalid %s channel excitation frequency: %u\n", 1175 + fwnode_get_name(ch_node), val); 1176 + return -EINVAL; 1177 + } 1178 + 1179 + *(engine + 3) &= ~IQS626_CHx_ENG_3_TX_FREQ_MASK; 1180 + *(engine + 3) |= (val << IQS626_CHx_ENG_3_TX_FREQ_SHIFT); 1181 + } 1182 + 1183 + *(engine + 3) &= ~IQS626_CHx_ENG_3_INV_LOGIC; 1184 + if (fwnode_property_present(ch_node, "azoteq,invert-enable")) 1185 + *(engine + 3) |= IQS626_CHx_ENG_3_INV_LOGIC; 1186 + 1187 + *(engine + 4) &= ~IQS626_CHx_ENG_4_COMP_DISABLE; 1188 + if (fwnode_property_present(ch_node, "azoteq,comp-disable")) 1189 + *(engine + 4) |= IQS626_CHx_ENG_4_COMP_DISABLE; 1190 + 1191 + *(engine + 4) &= ~IQS626_CHx_ENG_4_STATIC_ENABLE; 1192 + if (fwnode_property_present(ch_node, "azoteq,static-enable")) 1193 + *(engine + 4) |= IQS626_CHx_ENG_4_STATIC_ENABLE; 1194 + 1195 + i = ch_id - IQS626_CH_GEN_0; 1196 + assoc_select = &sys_reg->ch_reg_gen[i].assoc_select; 1197 + assoc_weight = &sys_reg->ch_reg_gen[i].assoc_weight; 1198 + 1199 + *assoc_select = 0; 1200 + if (!fwnode_property_present(ch_node, "azoteq,assoc-select")) 1201 + return 0; 1202 + 1203 + for (i = 0; i < ARRAY_SIZE(iqs626_channels); i++) { 1204 + if (fwnode_property_match_string(ch_node, "azoteq,assoc-select", 1205 + iqs626_channels[i].name) < 0) 1206 + continue; 1207 + 1208 + *assoc_select |= iqs626_channels[i].active; 1209 + } 1210 + 1211 + if (fwnode_property_read_u32(ch_node, "azoteq,assoc-weight", &val)) 1212 + return 0; 1213 + 1214 + if (val > IQS626_GEN_WEIGHT_MAX) { 1215 + dev_err(&client->dev, 1216 + "Invalid %s channel associated weight: %u\n", 1217 + fwnode_get_name(ch_node), val); 1218 + return -EINVAL; 1219 + } 1220 + 1221 + *assoc_weight = val; 1222 + 1223 + return 0; 1224 + } 1225 + 1226 + static int iqs626_parse_prop(struct iqs626_private *iqs626) 1227 + { 1228 + struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg; 1229 + struct i2c_client *client = iqs626->client; 1230 + struct fwnode_handle *ch_node; 1231 + unsigned int val; 1232 + int error, i; 1233 + u16 general; 1234 + 1235 + if (!device_property_read_u32(&client->dev, "azoteq,suspend-mode", 1236 + &val)) { 1237 + if (val > IQS626_SYS_SETTINGS_PWR_MODE_MAX) { 1238 + dev_err(&client->dev, "Invalid suspend mode: %u\n", 1239 + val); 1240 + return -EINVAL; 1241 + } 1242 + 1243 + iqs626->suspend_mode = val; 1244 + } 1245 + 1246 + error = regmap_raw_read(iqs626->regmap, IQS626_SYS_SETTINGS, sys_reg, 1247 + sizeof(*sys_reg)); 1248 + if (error) 1249 + return error; 1250 + 1251 + general = be16_to_cpu(sys_reg->general); 1252 + general &= IQS626_SYS_SETTINGS_ULP_UPDATE_MASK; 1253 + 1254 + if (device_property_present(&client->dev, "azoteq,clk-div")) 1255 + general |= IQS626_SYS_SETTINGS_CLK_DIV; 1256 + 1257 + if (device_property_present(&client->dev, "azoteq,ulp-enable")) 1258 + general |= IQS626_SYS_SETTINGS_ULP_AUTO; 1259 + 1260 + if (!device_property_read_u32(&client->dev, "azoteq,ulp-update", 1261 + &val)) { 1262 + if (val > IQS626_SYS_SETTINGS_ULP_UPDATE_MAX) { 1263 + dev_err(&client->dev, "Invalid update rate: %u\n", val); 1264 + return -EINVAL; 1265 + } 1266 + 1267 + general &= ~IQS626_SYS_SETTINGS_ULP_UPDATE_MASK; 1268 + general |= (val << IQS626_SYS_SETTINGS_ULP_UPDATE_SHIFT); 1269 + } 1270 + 1271 + sys_reg->misc_a &= ~IQS626_MISC_A_ATI_BAND_DISABLE; 1272 + if (device_property_present(&client->dev, "azoteq,ati-band-disable")) 1273 + sys_reg->misc_a |= IQS626_MISC_A_ATI_BAND_DISABLE; 1274 + 1275 + sys_reg->misc_a &= ~IQS626_MISC_A_ATI_LP_ONLY; 1276 + if (device_property_present(&client->dev, "azoteq,ati-lp-only")) 1277 + sys_reg->misc_a |= IQS626_MISC_A_ATI_LP_ONLY; 1278 + 1279 + if (!device_property_read_u32(&client->dev, "azoteq,gpio3-select", 1280 + &val)) { 1281 + if (val > IQS626_MISC_A_GPIO3_SELECT_MAX) { 1282 + dev_err(&client->dev, "Invalid GPIO3 selection: %u\n", 1283 + val); 1284 + return -EINVAL; 1285 + } 1286 + 1287 + sys_reg->misc_a &= ~IQS626_MISC_A_GPIO3_SELECT_MASK; 1288 + sys_reg->misc_a |= val; 1289 + } 1290 + 1291 + if (!device_property_read_u32(&client->dev, "azoteq,reseed-select", 1292 + &val)) { 1293 + if (val > IQS626_MISC_B_RESEED_UI_SEL_MAX) { 1294 + dev_err(&client->dev, "Invalid reseed selection: %u\n", 1295 + val); 1296 + return -EINVAL; 1297 + } 1298 + 1299 + sys_reg->misc_b &= ~IQS626_MISC_B_RESEED_UI_SEL_MASK; 1300 + sys_reg->misc_b |= (val << IQS626_MISC_B_RESEED_UI_SEL_SHIFT); 1301 + } 1302 + 1303 + sys_reg->misc_b &= ~IQS626_MISC_B_THRESH_EXTEND; 1304 + if (device_property_present(&client->dev, "azoteq,thresh-extend")) 1305 + sys_reg->misc_b |= IQS626_MISC_B_THRESH_EXTEND; 1306 + 1307 + sys_reg->misc_b &= ~IQS626_MISC_B_TRACKING_UI_ENABLE; 1308 + if (device_property_present(&client->dev, "azoteq,tracking-enable")) 1309 + sys_reg->misc_b |= IQS626_MISC_B_TRACKING_UI_ENABLE; 1310 + 1311 + sys_reg->misc_b &= ~IQS626_MISC_B_RESEED_OFFSET; 1312 + if (device_property_present(&client->dev, "azoteq,reseed-offset")) 1313 + sys_reg->misc_b |= IQS626_MISC_B_RESEED_OFFSET; 1314 + 1315 + if (!device_property_read_u32(&client->dev, "azoteq,rate-np-ms", 1316 + &val)) { 1317 + if (val > IQS626_RATE_NP_MS_MAX) { 1318 + dev_err(&client->dev, "Invalid report rate: %u\n", val); 1319 + return -EINVAL; 1320 + } 1321 + 1322 + sys_reg->rate_np = val; 1323 + } 1324 + 1325 + if (!device_property_read_u32(&client->dev, "azoteq,rate-lp-ms", 1326 + &val)) { 1327 + if (val > IQS626_RATE_LP_MS_MAX) { 1328 + dev_err(&client->dev, "Invalid report rate: %u\n", val); 1329 + return -EINVAL; 1330 + } 1331 + 1332 + sys_reg->rate_lp = val; 1333 + } 1334 + 1335 + if (!device_property_read_u32(&client->dev, "azoteq,rate-ulp-ms", 1336 + &val)) { 1337 + if (val > IQS626_RATE_ULP_MS_MAX) { 1338 + dev_err(&client->dev, "Invalid report rate: %u\n", val); 1339 + return -EINVAL; 1340 + } 1341 + 1342 + sys_reg->rate_ulp = val / 16; 1343 + } 1344 + 1345 + if (!device_property_read_u32(&client->dev, "azoteq,timeout-pwr-ms", 1346 + &val)) { 1347 + if (val > IQS626_TIMEOUT_PWR_MS_MAX) { 1348 + dev_err(&client->dev, "Invalid timeout: %u\n", val); 1349 + return -EINVAL; 1350 + } 1351 + 1352 + sys_reg->timeout_pwr = val / 512; 1353 + } 1354 + 1355 + if (!device_property_read_u32(&client->dev, "azoteq,timeout-lta-ms", 1356 + &val)) { 1357 + if (val > IQS626_TIMEOUT_LTA_MS_MAX) { 1358 + dev_err(&client->dev, "Invalid timeout: %u\n", val); 1359 + return -EINVAL; 1360 + } 1361 + 1362 + sys_reg->timeout_lta = val / 512; 1363 + } 1364 + 1365 + sys_reg->event_mask = ~((u8)IQS626_EVENT_MASK_SYS); 1366 + sys_reg->redo_ati = 0; 1367 + 1368 + sys_reg->reseed = 0; 1369 + sys_reg->active = 0; 1370 + 1371 + for (i = 0; i < ARRAY_SIZE(iqs626_channels); i++) { 1372 + ch_node = device_get_named_child_node(&client->dev, 1373 + iqs626_channels[i].name); 1374 + if (!ch_node) 1375 + continue; 1376 + 1377 + error = iqs626_parse_channel(iqs626, ch_node, i); 1378 + if (error) 1379 + return error; 1380 + 1381 + error = iqs626_parse_ati_target(iqs626, ch_node, i); 1382 + if (error) 1383 + return error; 1384 + 1385 + error = iqs626_parse_events(iqs626, ch_node, i); 1386 + if (error) 1387 + return error; 1388 + 1389 + if (!fwnode_property_present(ch_node, "azoteq,ati-exclude")) 1390 + sys_reg->redo_ati |= iqs626_channels[i].active; 1391 + 1392 + if (!fwnode_property_present(ch_node, "azoteq,reseed-disable")) 1393 + sys_reg->reseed |= iqs626_channels[i].active; 1394 + 1395 + sys_reg->active |= iqs626_channels[i].active; 1396 + } 1397 + 1398 + general |= IQS626_SYS_SETTINGS_EVENT_MODE; 1399 + 1400 + /* 1401 + * Enable streaming during normal-power mode if the trackpad is used to 1402 + * report raw coordinates instead of gestures. In that case, the device 1403 + * returns to event mode during low-power mode. 1404 + */ 1405 + if (sys_reg->active & iqs626_channels[IQS626_CH_TP_2].active && 1406 + sys_reg->event_mask & IQS626_EVENT_MASK_GESTURE) 1407 + general |= IQS626_SYS_SETTINGS_EVENT_MODE_LP; 1408 + 1409 + general |= IQS626_SYS_SETTINGS_REDO_ATI; 1410 + general |= IQS626_SYS_SETTINGS_ACK_RESET; 1411 + 1412 + sys_reg->general = cpu_to_be16(general); 1413 + 1414 + error = regmap_raw_write(iqs626->regmap, IQS626_SYS_SETTINGS, 1415 + &iqs626->sys_reg, sizeof(iqs626->sys_reg)); 1416 + if (error) 1417 + return error; 1418 + 1419 + iqs626_irq_wait(); 1420 + 1421 + return 0; 1422 + } 1423 + 1424 + static int iqs626_input_init(struct iqs626_private *iqs626) 1425 + { 1426 + struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg; 1427 + struct i2c_client *client = iqs626->client; 1428 + int error, i, j; 1429 + 1430 + iqs626->keypad = devm_input_allocate_device(&client->dev); 1431 + if (!iqs626->keypad) 1432 + return -ENOMEM; 1433 + 1434 + iqs626->keypad->keycodemax = ARRAY_SIZE(iqs626->kp_code); 1435 + iqs626->keypad->keycode = iqs626->kp_code; 1436 + iqs626->keypad->keycodesize = sizeof(**iqs626->kp_code); 1437 + 1438 + iqs626->keypad->name = "iqs626a_keypad"; 1439 + iqs626->keypad->id.bustype = BUS_I2C; 1440 + 1441 + for (i = 0; i < ARRAY_SIZE(iqs626_channels); i++) { 1442 + if (!(sys_reg->active & iqs626_channels[i].active)) 1443 + continue; 1444 + 1445 + for (j = 0; j < ARRAY_SIZE(iqs626_events); j++) { 1446 + if (!iqs626->kp_type[i][j]) 1447 + continue; 1448 + 1449 + input_set_capability(iqs626->keypad, 1450 + iqs626->kp_type[i][j], 1451 + iqs626->kp_code[i][j]); 1452 + } 1453 + } 1454 + 1455 + if (!(sys_reg->active & iqs626_channels[IQS626_CH_TP_2].active)) 1456 + return 0; 1457 + 1458 + iqs626->trackpad = devm_input_allocate_device(&client->dev); 1459 + if (!iqs626->trackpad) 1460 + return -ENOMEM; 1461 + 1462 + iqs626->trackpad->keycodemax = ARRAY_SIZE(iqs626->tp_code); 1463 + iqs626->trackpad->keycode = iqs626->tp_code; 1464 + iqs626->trackpad->keycodesize = sizeof(*iqs626->tp_code); 1465 + 1466 + iqs626->trackpad->name = "iqs626a_trackpad"; 1467 + iqs626->trackpad->id.bustype = BUS_I2C; 1468 + 1469 + /* 1470 + * Present the trackpad as a traditional pointing device if no gestures 1471 + * have been mapped to a keycode. 1472 + */ 1473 + if (sys_reg->event_mask & IQS626_EVENT_MASK_GESTURE) { 1474 + u8 tp_mask = iqs626_channels[IQS626_CH_TP_3].active; 1475 + 1476 + input_set_capability(iqs626->trackpad, EV_KEY, BTN_TOUCH); 1477 + input_set_abs_params(iqs626->trackpad, ABS_Y, 0, 255, 0, 0); 1478 + 1479 + if ((sys_reg->active & tp_mask) == tp_mask) 1480 + input_set_abs_params(iqs626->trackpad, 1481 + ABS_X, 0, 255, 0, 0); 1482 + else 1483 + input_set_abs_params(iqs626->trackpad, 1484 + ABS_X, 0, 128, 0, 0); 1485 + 1486 + touchscreen_parse_properties(iqs626->trackpad, false, 1487 + &iqs626->prop); 1488 + } else { 1489 + for (i = 0; i < IQS626_NUM_GESTURES; i++) 1490 + if (iqs626->tp_code[i] != KEY_RESERVED) 1491 + input_set_capability(iqs626->trackpad, EV_KEY, 1492 + iqs626->tp_code[i]); 1493 + } 1494 + 1495 + error = input_register_device(iqs626->trackpad); 1496 + if (error) 1497 + dev_err(&client->dev, "Failed to register trackpad: %d\n", 1498 + error); 1499 + 1500 + return error; 1501 + } 1502 + 1503 + static int iqs626_report(struct iqs626_private *iqs626) 1504 + { 1505 + struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg; 1506 + struct i2c_client *client = iqs626->client; 1507 + struct iqs626_flags flags; 1508 + __le16 hall_output; 1509 + int error, i, j; 1510 + u8 state; 1511 + u8 *dir_mask = &flags.states[IQS626_ST_OFFS_DIR]; 1512 + 1513 + error = regmap_raw_read(iqs626->regmap, IQS626_SYS_FLAGS, &flags, 1514 + sizeof(flags)); 1515 + if (error) { 1516 + dev_err(&client->dev, "Failed to read device status: %d\n", 1517 + error); 1518 + return error; 1519 + } 1520 + 1521 + /* 1522 + * The device resets itself if its own watchdog bites, which can happen 1523 + * in the event of an I2C communication error. In this case, the device 1524 + * asserts a SHOW_RESET interrupt and all registers must be restored. 1525 + */ 1526 + if (be16_to_cpu(flags.system) & IQS626_SYS_FLAGS_SHOW_RESET) { 1527 + dev_err(&client->dev, "Unexpected device reset\n"); 1528 + 1529 + error = regmap_raw_write(iqs626->regmap, IQS626_SYS_SETTINGS, 1530 + sys_reg, sizeof(*sys_reg)); 1531 + if (error) 1532 + dev_err(&client->dev, 1533 + "Failed to re-initialize device: %d\n", error); 1534 + 1535 + return error; 1536 + } 1537 + 1538 + if (be16_to_cpu(flags.system) & IQS626_SYS_FLAGS_IN_ATI) 1539 + return 0; 1540 + 1541 + /* 1542 + * Unlike the ULP or generic channels, the Hall channel does not have a 1543 + * direction flag. Instead, the direction (i.e. magnet polarity) can be 1544 + * derived based on the sign of the 2's complement differential output. 1545 + */ 1546 + if (sys_reg->active & iqs626_channels[IQS626_CH_HALL].active) { 1547 + error = regmap_raw_read(iqs626->regmap, IQS626_HALL_OUTPUT, 1548 + &hall_output, sizeof(hall_output)); 1549 + if (error) { 1550 + dev_err(&client->dev, 1551 + "Failed to read Hall output: %d\n", error); 1552 + return error; 1553 + } 1554 + 1555 + *dir_mask &= ~iqs626_channels[IQS626_CH_HALL].active; 1556 + if (le16_to_cpu(hall_output) < 0x8000) 1557 + *dir_mask |= iqs626_channels[IQS626_CH_HALL].active; 1558 + } 1559 + 1560 + for (i = 0; i < ARRAY_SIZE(iqs626_channels); i++) { 1561 + if (!(sys_reg->active & iqs626_channels[i].active)) 1562 + continue; 1563 + 1564 + for (j = 0; j < ARRAY_SIZE(iqs626_events); j++) { 1565 + if (!iqs626->kp_type[i][j]) 1566 + continue; 1567 + 1568 + state = flags.states[iqs626_events[j].st_offs]; 1569 + state &= iqs626_events[j].dir_up ? *dir_mask 1570 + : ~(*dir_mask); 1571 + state &= iqs626_channels[i].active; 1572 + 1573 + input_event(iqs626->keypad, iqs626->kp_type[i][j], 1574 + iqs626->kp_code[i][j], !!state); 1575 + } 1576 + } 1577 + 1578 + input_sync(iqs626->keypad); 1579 + 1580 + /* 1581 + * The following completion signals that ATI has finished, any initial 1582 + * switch states have been reported and the keypad can be registered. 1583 + */ 1584 + complete_all(&iqs626->ati_done); 1585 + 1586 + if (!(sys_reg->active & iqs626_channels[IQS626_CH_TP_2].active)) 1587 + return 0; 1588 + 1589 + if (sys_reg->event_mask & IQS626_EVENT_MASK_GESTURE) { 1590 + state = flags.states[IQS626_ST_OFFS_TOUCH]; 1591 + state &= iqs626_channels[IQS626_CH_TP_2].active; 1592 + 1593 + input_report_key(iqs626->trackpad, BTN_TOUCH, state); 1594 + 1595 + if (state) 1596 + touchscreen_report_pos(iqs626->trackpad, &iqs626->prop, 1597 + flags.trackpad_x, 1598 + flags.trackpad_y, false); 1599 + } else { 1600 + for (i = 0; i < IQS626_NUM_GESTURES; i++) 1601 + input_report_key(iqs626->trackpad, iqs626->tp_code[i], 1602 + flags.gesture & BIT(i)); 1603 + 1604 + if (flags.gesture & GENMASK(IQS626_GESTURE_TAP, 0)) { 1605 + input_sync(iqs626->trackpad); 1606 + 1607 + /* 1608 + * Momentary gestures are followed by a complementary 1609 + * release cycle so as to emulate a full keystroke. 1610 + */ 1611 + for (i = 0; i < IQS626_GESTURE_HOLD; i++) 1612 + input_report_key(iqs626->trackpad, 1613 + iqs626->tp_code[i], 0); 1614 + } 1615 + } 1616 + 1617 + input_sync(iqs626->trackpad); 1618 + 1619 + return 0; 1620 + } 1621 + 1622 + static irqreturn_t iqs626_irq(int irq, void *context) 1623 + { 1624 + struct iqs626_private *iqs626 = context; 1625 + 1626 + if (iqs626_report(iqs626)) 1627 + return IRQ_NONE; 1628 + 1629 + /* 1630 + * The device does not deassert its interrupt (RDY) pin until shortly 1631 + * after receiving an I2C stop condition; the following delay ensures 1632 + * the interrupt handler does not return before this time. 1633 + */ 1634 + iqs626_irq_wait(); 1635 + 1636 + return IRQ_HANDLED; 1637 + } 1638 + 1639 + static const struct regmap_config iqs626_regmap_config = { 1640 + .reg_bits = 8, 1641 + .val_bits = 16, 1642 + .max_register = IQS626_MAX_REG, 1643 + }; 1644 + 1645 + static int iqs626_probe(struct i2c_client *client) 1646 + { 1647 + struct iqs626_ver_info ver_info; 1648 + struct iqs626_private *iqs626; 1649 + int error; 1650 + 1651 + iqs626 = devm_kzalloc(&client->dev, sizeof(*iqs626), GFP_KERNEL); 1652 + if (!iqs626) 1653 + return -ENOMEM; 1654 + 1655 + i2c_set_clientdata(client, iqs626); 1656 + iqs626->client = client; 1657 + 1658 + iqs626->regmap = devm_regmap_init_i2c(client, &iqs626_regmap_config); 1659 + if (IS_ERR(iqs626->regmap)) { 1660 + error = PTR_ERR(iqs626->regmap); 1661 + dev_err(&client->dev, "Failed to initialize register map: %d\n", 1662 + error); 1663 + return error; 1664 + } 1665 + 1666 + init_completion(&iqs626->ati_done); 1667 + 1668 + error = regmap_raw_read(iqs626->regmap, IQS626_VER_INFO, &ver_info, 1669 + sizeof(ver_info)); 1670 + if (error) 1671 + return error; 1672 + 1673 + if (ver_info.prod_num != IQS626_VER_INFO_PROD_NUM) { 1674 + dev_err(&client->dev, "Unrecognized product number: 0x%02X\n", 1675 + ver_info.prod_num); 1676 + return -EINVAL; 1677 + } 1678 + 1679 + error = iqs626_parse_prop(iqs626); 1680 + if (error) 1681 + return error; 1682 + 1683 + error = iqs626_input_init(iqs626); 1684 + if (error) 1685 + return error; 1686 + 1687 + error = devm_request_threaded_irq(&client->dev, client->irq, 1688 + NULL, iqs626_irq, IRQF_ONESHOT, 1689 + client->name, iqs626); 1690 + if (error) { 1691 + dev_err(&client->dev, "Failed to request IRQ: %d\n", error); 1692 + return error; 1693 + } 1694 + 1695 + if (!wait_for_completion_timeout(&iqs626->ati_done, 1696 + msecs_to_jiffies(2000))) { 1697 + dev_err(&client->dev, "Failed to complete ATI\n"); 1698 + return -ETIMEDOUT; 1699 + } 1700 + 1701 + /* 1702 + * The keypad may include one or more switches and is not registered 1703 + * until ATI is complete and the initial switch states are read. 1704 + */ 1705 + error = input_register_device(iqs626->keypad); 1706 + if (error) 1707 + dev_err(&client->dev, "Failed to register keypad: %d\n", error); 1708 + 1709 + return error; 1710 + } 1711 + 1712 + static int __maybe_unused iqs626_suspend(struct device *dev) 1713 + { 1714 + struct iqs626_private *iqs626 = dev_get_drvdata(dev); 1715 + struct i2c_client *client = iqs626->client; 1716 + unsigned int val; 1717 + int error; 1718 + 1719 + if (!iqs626->suspend_mode) 1720 + return 0; 1721 + 1722 + disable_irq(client->irq); 1723 + 1724 + /* 1725 + * Automatic power mode switching must be disabled before the device is 1726 + * forced into any particular power mode. In this case, the device will 1727 + * transition into normal-power mode. 1728 + */ 1729 + error = regmap_update_bits(iqs626->regmap, IQS626_SYS_SETTINGS, 1730 + IQS626_SYS_SETTINGS_DIS_AUTO, ~0); 1731 + if (error) 1732 + goto err_irq; 1733 + 1734 + /* 1735 + * The following check ensures the device has completed its transition 1736 + * into normal-power mode before a manual mode switch is performed. 1737 + */ 1738 + error = regmap_read_poll_timeout(iqs626->regmap, IQS626_SYS_FLAGS, val, 1739 + !(val & IQS626_SYS_FLAGS_PWR_MODE_MASK), 1740 + IQS626_PWR_MODE_POLL_SLEEP_US, 1741 + IQS626_PWR_MODE_POLL_TIMEOUT_US); 1742 + if (error) 1743 + goto err_irq; 1744 + 1745 + error = regmap_update_bits(iqs626->regmap, IQS626_SYS_SETTINGS, 1746 + IQS626_SYS_SETTINGS_PWR_MODE_MASK, 1747 + iqs626->suspend_mode << 1748 + IQS626_SYS_SETTINGS_PWR_MODE_SHIFT); 1749 + if (error) 1750 + goto err_irq; 1751 + 1752 + /* 1753 + * This last check ensures the device has completed its transition into 1754 + * the desired power mode to prevent any spurious interrupts from being 1755 + * triggered after iqs626_suspend has already returned. 1756 + */ 1757 + error = regmap_read_poll_timeout(iqs626->regmap, IQS626_SYS_FLAGS, val, 1758 + (val & IQS626_SYS_FLAGS_PWR_MODE_MASK) 1759 + == (iqs626->suspend_mode << 1760 + IQS626_SYS_FLAGS_PWR_MODE_SHIFT), 1761 + IQS626_PWR_MODE_POLL_SLEEP_US, 1762 + IQS626_PWR_MODE_POLL_TIMEOUT_US); 1763 + 1764 + err_irq: 1765 + iqs626_irq_wait(); 1766 + enable_irq(client->irq); 1767 + 1768 + return error; 1769 + } 1770 + 1771 + static int __maybe_unused iqs626_resume(struct device *dev) 1772 + { 1773 + struct iqs626_private *iqs626 = dev_get_drvdata(dev); 1774 + struct i2c_client *client = iqs626->client; 1775 + unsigned int val; 1776 + int error; 1777 + 1778 + if (!iqs626->suspend_mode) 1779 + return 0; 1780 + 1781 + disable_irq(client->irq); 1782 + 1783 + error = regmap_update_bits(iqs626->regmap, IQS626_SYS_SETTINGS, 1784 + IQS626_SYS_SETTINGS_PWR_MODE_MASK, 0); 1785 + if (error) 1786 + goto err_irq; 1787 + 1788 + /* 1789 + * This check ensures the device has returned to normal-power mode 1790 + * before automatic power mode switching is re-enabled. 1791 + */ 1792 + error = regmap_read_poll_timeout(iqs626->regmap, IQS626_SYS_FLAGS, val, 1793 + !(val & IQS626_SYS_FLAGS_PWR_MODE_MASK), 1794 + IQS626_PWR_MODE_POLL_SLEEP_US, 1795 + IQS626_PWR_MODE_POLL_TIMEOUT_US); 1796 + if (error) 1797 + goto err_irq; 1798 + 1799 + error = regmap_update_bits(iqs626->regmap, IQS626_SYS_SETTINGS, 1800 + IQS626_SYS_SETTINGS_DIS_AUTO, 0); 1801 + if (error) 1802 + goto err_irq; 1803 + 1804 + /* 1805 + * This step reports any events that may have been "swallowed" as a 1806 + * result of polling PWR_MODE (which automatically acknowledges any 1807 + * pending interrupts). 1808 + */ 1809 + error = iqs626_report(iqs626); 1810 + 1811 + err_irq: 1812 + iqs626_irq_wait(); 1813 + enable_irq(client->irq); 1814 + 1815 + return error; 1816 + } 1817 + 1818 + static SIMPLE_DEV_PM_OPS(iqs626_pm, iqs626_suspend, iqs626_resume); 1819 + 1820 + static const struct of_device_id iqs626_of_match[] = { 1821 + { .compatible = "azoteq,iqs626a" }, 1822 + { } 1823 + }; 1824 + MODULE_DEVICE_TABLE(of, iqs626_of_match); 1825 + 1826 + static struct i2c_driver iqs626_i2c_driver = { 1827 + .driver = { 1828 + .name = "iqs626a", 1829 + .of_match_table = iqs626_of_match, 1830 + .pm = &iqs626_pm, 1831 + }, 1832 + .probe_new = iqs626_probe, 1833 + }; 1834 + module_i2c_driver(iqs626_i2c_driver); 1835 + 1836 + MODULE_AUTHOR("Jeff LaBundy <jeff@labundy.com>"); 1837 + MODULE_DESCRIPTION("Azoteq IQS626A Capacitive Touch Controller"); 1838 + MODULE_LICENSE("GPL");
+2 -7
drivers/input/misc/max8997_haptic.c
··· 61 61 unsigned int duty = chip->pwm_period * chip->level / 100; 62 62 ret = pwm_config(chip->pwm, duty, chip->pwm_period); 63 63 } else { 64 - int i; 65 64 u8 duty_index = 0; 66 65 67 - for (i = 0; i <= 64; i++) { 68 - if (chip->level <= i * 100 / 64) { 69 - duty_index = i; 70 - break; 71 - } 72 - } 66 + duty_index = DIV_ROUND_UP(chip->level * 64, 100); 67 + 73 68 switch (chip->internal_mode_pattern) { 74 69 case 0: 75 70 max8997_write_reg(chip->client,
+6 -1
drivers/input/mouse/elan_i2c.h
··· 55 55 #define ETP_FW_PAGE_SIZE_512 512 56 56 #define ETP_FW_SIGNATURE_SIZE 6 57 57 58 + #define ETP_PRODUCT_ID_DELBIN 0x00C2 59 + #define ETP_PRODUCT_ID_VOXEL 0x00BF 60 + #define ETP_PRODUCT_ID_MAGPIE 0x0120 61 + #define ETP_PRODUCT_ID_BOBBA 0x0121 62 + 58 63 struct i2c_client; 59 64 struct completion; 60 65 ··· 78 73 int (*calibrate_result)(struct i2c_client *client, u8 *val); 79 74 80 75 int (*get_baseline_data)(struct i2c_client *client, 81 - bool max_baseliune, u8 *value); 76 + bool max_baseline, u8 *value); 82 77 83 78 int (*get_version)(struct i2c_client *client, u8 pattern, bool iap, 84 79 u8 *version);
+48 -10
drivers/input/mouse/elan_i2c_core.c
··· 46 46 #define ETP_FINGER_WIDTH 15 47 47 #define ETP_RETRY_COUNT 3 48 48 49 + /* quirks to control the device */ 50 + #define ETP_QUIRK_QUICK_WAKEUP BIT(0) 51 + 49 52 /* The main device structure */ 50 53 struct elan_tp_data { 51 54 struct i2c_client *client; ··· 93 90 bool baseline_ready; 94 91 u8 clickpad; 95 92 bool middle_button; 93 + 94 + u32 quirks; /* Various quirks */ 96 95 }; 96 + 97 + static u32 elan_i2c_lookup_quirks(u16 ic_type, u16 product_id) 98 + { 99 + static const struct { 100 + u16 ic_type; 101 + u16 product_id; 102 + u32 quirks; 103 + } elan_i2c_quirks[] = { 104 + { 0x0D, ETP_PRODUCT_ID_DELBIN, ETP_QUIRK_QUICK_WAKEUP }, 105 + { 0x10, ETP_PRODUCT_ID_VOXEL, ETP_QUIRK_QUICK_WAKEUP }, 106 + { 0x14, ETP_PRODUCT_ID_MAGPIE, ETP_QUIRK_QUICK_WAKEUP }, 107 + { 0x14, ETP_PRODUCT_ID_BOBBA, ETP_QUIRK_QUICK_WAKEUP }, 108 + }; 109 + u32 quirks = 0; 110 + int i; 111 + 112 + for (i = 0; i < ARRAY_SIZE(elan_i2c_quirks); i++) { 113 + if (elan_i2c_quirks[i].ic_type == ic_type && 114 + elan_i2c_quirks[i].product_id == product_id) { 115 + quirks = elan_i2c_quirks[i].quirks; 116 + } 117 + } 118 + 119 + if (ic_type >= 0x0D && product_id >= 0x123) 120 + quirks |= ETP_QUIRK_QUICK_WAKEUP; 121 + 122 + return quirks; 123 + } 97 124 98 125 static int elan_get_fwinfo(u16 ic_type, u8 iap_version, u16 *validpage_count, 99 126 u32 *signature_address, u16 *page_size) ··· 291 258 return false; 292 259 } 293 260 294 - static int __elan_initialize(struct elan_tp_data *data) 261 + static int __elan_initialize(struct elan_tp_data *data, bool skip_reset) 295 262 { 296 263 struct i2c_client *client = data->client; 297 264 bool woken_up = false; 298 265 int error; 299 266 300 - error = data->ops->initialize(client); 301 - if (error) { 302 - dev_err(&client->dev, "device initialize failed: %d\n", error); 303 - return error; 267 + if (!skip_reset) { 268 + error = data->ops->initialize(client); 269 + if (error) { 270 + dev_err(&client->dev, "device initialize failed: %d\n", error); 271 + return error; 272 + } 304 273 } 305 274 306 275 error = elan_query_product(data); ··· 346 311 return 0; 347 312 } 348 313 349 - static int elan_initialize(struct elan_tp_data *data) 314 + static int elan_initialize(struct elan_tp_data *data, bool skip_reset) 350 315 { 351 316 int repeat = ETP_RETRY_COUNT; 352 317 int error; 353 318 354 319 do { 355 - error = __elan_initialize(data); 320 + error = __elan_initialize(data, skip_reset); 356 321 if (!error) 357 322 return 0; 358 323 324 + skip_reset = false; 359 325 msleep(30); 360 326 } while (--repeat > 0); 361 327 ··· 392 356 &data->report_len); 393 357 if (error) 394 358 return error; 359 + 360 + data->quirks = elan_i2c_lookup_quirks(data->ic_type, data->product_id); 395 361 396 362 error = elan_get_fwinfo(data->ic_type, data->iap_version, 397 363 &data->fw_validpage_count, ··· 584 546 data->ops->iap_reset(client); 585 547 } else { 586 548 /* Reinitialize TP after fw is updated */ 587 - elan_initialize(data); 549 + elan_initialize(data, false); 588 550 elan_query_device_info(data); 589 551 } 590 552 ··· 1285 1247 } 1286 1248 1287 1249 /* Initialize the touchpad. */ 1288 - error = elan_initialize(data); 1250 + error = elan_initialize(data, false); 1289 1251 if (error) 1290 1252 return error; 1291 1253 ··· 1422 1384 goto err; 1423 1385 } 1424 1386 1425 - error = elan_initialize(data); 1387 + error = elan_initialize(data, data->quirks & ETP_QUIRK_QUICK_WAKEUP); 1426 1388 if (error) 1427 1389 dev_err(dev, "initialize when resuming failed: %d\n", error); 1428 1390
+1 -2
drivers/input/serio/apbps2.c
··· 103 103 { 104 104 struct apbps2_priv *priv = io->port_data; 105 105 int limit; 106 - unsigned long tmp; 107 106 108 107 /* clear error flags */ 109 108 iowrite32be(0, &priv->regs->status); ··· 110 111 /* Clear old data if available (unlikely) */ 111 112 limit = 1024; 112 113 while ((ioread32be(&priv->regs->status) & APBPS2_STATUS_DR) && --limit) 113 - tmp = ioread32be(&priv->regs->data); 114 + ioread32be(&priv->regs->data); 114 115 115 116 /* Enable reciever and it's interrupt */ 116 117 iowrite32be(APBPS2_CTRL_RE | APBPS2_CTRL_RI, &priv->regs->ctrl);
+35 -4
drivers/input/touchscreen/Kconfig
··· 12 12 13 13 if INPUT_TOUCHSCREEN 14 14 15 - config TOUCHSCREEN_PROPERTIES 16 - def_tristate INPUT 17 - depends on INPUT 18 - 19 15 config TOUCHSCREEN_88PM860X 20 16 tristate "Marvell 88PM860x touchscreen" 21 17 depends on MFD_88PM860X ··· 411 415 To compile this driver as a module, choose M here : the 412 416 module will be called hideep_ts. 413 417 418 + config TOUCHSCREEN_HYCON_HY46XX 419 + tristate "Hycon hy46xx touchscreen support" 420 + depends on I2C 421 + help 422 + Say Y here if you have a touchscreen using Hycon hy46xx 423 + 424 + If unsure, say N. 425 + 426 + To compile this driver as a module, choose M here: the 427 + module will be called hycon-hy46xx. 428 + 414 429 config TOUCHSCREEN_ILI210X 415 430 tristate "Ilitek ILI210X based touchscreen" 416 431 depends on I2C ··· 436 429 437 430 To compile this driver as a module, choose M here: the 438 431 module will be called ili210x. 432 + 433 + config TOUCHSCREEN_ILITEK 434 + tristate "Ilitek I2C 213X/23XX/25XX/Lego Series Touch ICs" 435 + depends on I2C 436 + help 437 + Say Y here if you have touchscreen with ILITEK touch IC, 438 + it supports 213X/23XX/25XX and other Lego series. 439 + 440 + If unsure, say N. 441 + 442 + To compile this driver as a module, choose M here: the 443 + module will be called ilitek_ts_i2c. 439 444 440 445 config TOUCHSCREEN_IPROC 441 446 tristate "IPROC touch panel driver support" ··· 612 593 613 594 To compile this driver as a module, choose M here: 614 595 the module will be called melfas_mip4. 596 + 597 + config TOUCHSCREEN_MSG2638 598 + tristate "MStar msg2638 touchscreen support" 599 + depends on I2C 600 + depends on GPIOLIB || COMPILE_TEST 601 + help 602 + Say Y here if you have an I2C touchscreen using MStar msg2638. 603 + 604 + If unsure, say N. 605 + 606 + To compile this driver as a module, choose M here: the 607 + module will be called msg2638. 615 608 616 609 config TOUCHSCREEN_MTOUCH 617 610 tristate "MicroTouch serial touchscreens"
+3 -1
drivers/input/touchscreen/Makefile
··· 7 7 8 8 wm97xx-ts-y := wm97xx-core.o 9 9 10 - obj-$(CONFIG_TOUCHSCREEN_PROPERTIES) += of_touchscreen.o 11 10 obj-$(CONFIG_TOUCHSCREEN_88PM860X) += 88pm860x-ts.o 12 11 obj-$(CONFIG_TOUCHSCREEN_AD7877) += ad7877.o 13 12 obj-$(CONFIG_TOUCHSCREEN_AD7879) += ad7879.o ··· 34 35 obj-$(CONFIG_TOUCHSCREEN_DYNAPRO) += dynapro.o 35 36 obj-$(CONFIG_TOUCHSCREEN_EDT_FT5X06) += edt-ft5x06.o 36 37 obj-$(CONFIG_TOUCHSCREEN_HAMPSHIRE) += hampshire.o 38 + obj-$(CONFIG_TOUCHSCREEN_HYCON_HY46XX) += hycon-hy46xx.o 37 39 obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o 38 40 obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o 39 41 obj-$(CONFIG_TOUCHSCREEN_EKTF2127) += ektf2127.o ··· 47 47 obj-$(CONFIG_TOUCHSCREEN_GOODIX) += goodix.o 48 48 obj-$(CONFIG_TOUCHSCREEN_HIDEEP) += hideep.o 49 49 obj-$(CONFIG_TOUCHSCREEN_ILI210X) += ili210x.o 50 + obj-$(CONFIG_TOUCHSCREEN_ILITEK) += ilitek_ts_i2c.o 50 51 obj-$(CONFIG_TOUCHSCREEN_IMX6UL_TSC) += imx6ul_tsc.o 51 52 obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o 52 53 obj-$(CONFIG_TOUCHSCREEN_IPROC) += bcm_iproc_tsc.o ··· 60 59 obj-$(CONFIG_TOUCHSCREEN_MELFAS_MIP4) += melfas_mip4.o 61 60 obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o 62 61 obj-$(CONFIG_TOUCHSCREEN_MMS114) += mms114.o 62 + obj-$(CONFIG_TOUCHSCREEN_MSG2638) += msg2638.o 63 63 obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o 64 64 obj-$(CONFIG_TOUCHSCREEN_MK712) += mk712.o 65 65 obj-$(CONFIG_TOUCHSCREEN_HP600) += hp680_ts_input.o
+1 -4
drivers/input/touchscreen/ar1021_i2c.c
··· 125 125 126 126 error = devm_request_threaded_irq(&client->dev, client->irq, 127 127 NULL, ar1021_i2c_irq, 128 - IRQF_ONESHOT, 128 + IRQF_ONESHOT | IRQF_NO_AUTOEN, 129 129 "ar1021_i2c", ar1021); 130 130 if (error) { 131 131 dev_err(&client->dev, 132 132 "Failed to enable IRQ, error: %d\n", error); 133 133 return error; 134 134 } 135 - 136 - /* Disable the IRQ, we'll enable it in ar1021_i2c_open() */ 137 - disable_irq(client->irq); 138 135 139 136 error = input_register_device(ar1021->input); 140 137 if (error) {
+80 -3
drivers/input/touchscreen/atmel_mxt_ts.c
··· 31 31 #include <media/v4l2-ioctl.h> 32 32 #include <media/videobuf2-v4l2.h> 33 33 #include <media/videobuf2-vmalloc.h> 34 + #include <dt-bindings/input/atmel-maxtouch.h> 34 35 35 36 /* Firmware files */ 36 37 #define MXT_FW_NAME "maxtouch.fw" ··· 200 199 #define MXT_CRC_TIMEOUT 1000 /* msec */ 201 200 #define MXT_FW_RESET_TIME 3000 /* msec */ 202 201 #define MXT_FW_CHG_TIMEOUT 300 /* msec */ 202 + #define MXT_WAKEUP_TIME 25 /* msec */ 203 203 204 204 /* Command to unlock bootloader */ 205 205 #define MXT_UNLOCK_CMD_MSB 0xaa ··· 314 312 struct mxt_dbg dbg; 315 313 struct regulator_bulk_data regulators[2]; 316 314 struct gpio_desc *reset_gpio; 315 + struct gpio_desc *wake_gpio; 317 316 bool use_retrigen_workaround; 318 317 319 318 /* Cached parameters from object table */ ··· 345 342 unsigned int t19_num_keys; 346 343 347 344 enum mxt_suspend_mode suspend_mode; 345 + 346 + u32 wakeup_method; 348 347 }; 349 348 350 349 struct mxt_vb2_buffer { ··· 626 621 return mxt_bootloader_write(data, buf, sizeof(buf)); 627 622 } 628 623 624 + static bool mxt_wakeup_toggle(struct i2c_client *client, 625 + bool wake_up, bool in_i2c) 626 + { 627 + struct mxt_data *data = i2c_get_clientdata(client); 628 + 629 + switch (data->wakeup_method) { 630 + case ATMEL_MXT_WAKEUP_I2C_SCL: 631 + if (!in_i2c) 632 + return false; 633 + break; 634 + 635 + case ATMEL_MXT_WAKEUP_GPIO: 636 + if (in_i2c) 637 + return false; 638 + 639 + gpiod_set_value(data->wake_gpio, wake_up); 640 + break; 641 + 642 + default: 643 + return false; 644 + } 645 + 646 + if (wake_up) { 647 + dev_dbg(&client->dev, "waking up controller\n"); 648 + 649 + msleep(MXT_WAKEUP_TIME); 650 + } 651 + 652 + return true; 653 + } 654 + 629 655 static int __mxt_read_reg(struct i2c_client *client, 630 656 u16 reg, u16 len, void *val) 631 657 { 632 658 struct i2c_msg xfer[2]; 659 + bool retried = false; 633 660 u8 buf[2]; 634 661 int ret; 635 662 ··· 680 643 xfer[1].len = len; 681 644 xfer[1].buf = val; 682 645 646 + retry: 683 647 ret = i2c_transfer(client->adapter, xfer, 2); 684 648 if (ret == 2) { 685 649 ret = 0; 650 + } else if (!retried && mxt_wakeup_toggle(client, true, true)) { 651 + retried = true; 652 + goto retry; 686 653 } else { 687 654 if (ret >= 0) 688 655 ret = -EIO; ··· 700 659 static int __mxt_write_reg(struct i2c_client *client, u16 reg, u16 len, 701 660 const void *val) 702 661 { 662 + bool retried = false; 703 663 u8 *buf; 704 664 size_t count; 705 665 int ret; ··· 714 672 buf[1] = (reg >> 8) & 0xff; 715 673 memcpy(&buf[2], val, len); 716 674 675 + retry: 717 676 ret = i2c_master_send(client, buf, count); 718 677 if (ret == count) { 719 678 ret = 0; 679 + } else if (!retried && mxt_wakeup_toggle(client, true, true)) { 680 + retried = true; 681 + goto retry; 720 682 } else { 721 683 if (ret >= 0) 722 684 ret = -EIO; ··· 3021 2975 3022 2976 static void mxt_start(struct mxt_data *data) 3023 2977 { 2978 + mxt_wakeup_toggle(data->client, true, false); 2979 + 3024 2980 switch (data->suspend_mode) { 3025 2981 case MXT_SUSPEND_T9_CTRL: 3026 2982 mxt_soft_reset(data); ··· 3057 3009 mxt_set_t7_power_cfg(data, MXT_POWER_CFG_DEEPSLEEP); 3058 3010 break; 3059 3011 } 3012 + 3013 + mxt_wakeup_toggle(data->client, false, false); 3060 3014 } 3061 3015 3062 3016 static int mxt_input_open(struct input_dev *dev) ··· 3205 3155 return error; 3206 3156 } 3207 3157 3158 + /* Request the WAKE line as asserted so we go out of sleep */ 3159 + data->wake_gpio = devm_gpiod_get_optional(&client->dev, 3160 + "wake", GPIOD_OUT_HIGH); 3161 + if (IS_ERR(data->wake_gpio)) { 3162 + error = PTR_ERR(data->wake_gpio); 3163 + dev_err(&client->dev, "Failed to get wake gpio: %d\n", error); 3164 + return error; 3165 + } 3166 + 3208 3167 error = devm_request_threaded_irq(&client->dev, client->irq, 3209 - NULL, mxt_interrupt, IRQF_ONESHOT, 3168 + NULL, mxt_interrupt, 3169 + IRQF_ONESHOT | IRQF_NO_AUTOEN, 3210 3170 client->name, data); 3211 3171 if (error) { 3212 3172 dev_err(&client->dev, "Failed to register interrupt\n"); 3213 3173 return error; 3214 3174 } 3215 - 3216 - disable_irq(client->irq); 3217 3175 3218 3176 error = regulator_bulk_enable(ARRAY_SIZE(data->regulators), 3219 3177 data->regulators); ··· 3242 3184 gpiod_set_value(data->reset_gpio, 0); 3243 3185 msleep(MXT_RESET_INVALID_CHG); 3244 3186 } 3187 + 3188 + /* 3189 + * Controllers like mXT1386 have a dedicated WAKE line that could be 3190 + * connected to a GPIO or to I2C SCL pin, or permanently asserted low. 3191 + * 3192 + * This WAKE line is used for waking controller from a deep-sleep and 3193 + * it needs to be asserted low for 25 milliseconds before I2C transfers 3194 + * could be accepted by controller if it was in a deep-sleep mode. 3195 + * Controller will go into sleep automatically after 2 seconds of 3196 + * inactivity if WAKE line is deasserted and deep sleep is activated. 3197 + * 3198 + * If WAKE line is connected to I2C SCL pin, then the first I2C transfer 3199 + * will get an instant NAK and transfer needs to be retried after 25ms. 3200 + * 3201 + * If WAKE line is connected to a GPIO line, the line must be asserted 3202 + * 25ms before the host attempts to communicate with the controller. 3203 + */ 3204 + device_property_read_u32(&client->dev, "atmel,wakeup-method", 3205 + &data->wakeup_method); 3245 3206 3246 3207 error = mxt_initialize(data); 3247 3208 if (error)
+2 -2
drivers/input/touchscreen/bu21029_ts.c
··· 401 401 402 402 input_set_drvdata(in_dev, bu21029); 403 403 404 - irq_set_status_flags(client->irq, IRQ_NOAUTOEN); 405 404 error = devm_request_threaded_irq(&client->dev, client->irq, 406 405 NULL, bu21029_touch_soft_irq, 407 - IRQF_ONESHOT, DRIVER_NAME, bu21029); 406 + IRQF_ONESHOT | IRQF_NO_AUTOEN, 407 + DRIVER_NAME, bu21029); 408 408 if (error) { 409 409 dev_err(&client->dev, 410 410 "unable to request touch irq: %d\n", error);
+25 -14
drivers/input/touchscreen/cyttsp_core.c
··· 229 229 static void cyttsp_hard_reset(struct cyttsp *ts) 230 230 { 231 231 if (ts->reset_gpio) { 232 + /* 233 + * According to the CY8CTMA340 datasheet page 21, the external 234 + * reset pulse width should be >= 1 ms. The datasheet does not 235 + * specify how long we have to wait after reset but a vendor 236 + * tree specifies 5 ms here. 237 + */ 232 238 gpiod_set_value_cansleep(ts->reset_gpio, 1); 233 - msleep(CY_DELAY_DFLT); 239 + usleep_range(1000, 2000); 234 240 gpiod_set_value_cansleep(ts->reset_gpio, 0); 235 - msleep(CY_DELAY_DFLT); 241 + usleep_range(5000, 6000); 236 242 } 237 243 } 238 244 239 245 static int cyttsp_soft_reset(struct cyttsp *ts) 240 246 { 241 - unsigned long timeout; 242 247 int retval; 243 248 244 249 /* wait for interrupt to set ready completion */ ··· 253 248 enable_irq(ts->irq); 254 249 255 250 retval = ttsp_send_command(ts, CY_SOFT_RESET_MODE); 256 - if (retval) 251 + if (retval) { 252 + dev_err(ts->dev, "failed to send soft reset\n"); 257 253 goto out; 254 + } 258 255 259 - timeout = wait_for_completion_timeout(&ts->bl_ready, 260 - msecs_to_jiffies(CY_DELAY_DFLT * CY_DELAY_MAX)); 261 - retval = timeout ? 0 : -EIO; 256 + if (!wait_for_completion_timeout(&ts->bl_ready, 257 + msecs_to_jiffies(CY_DELAY_DFLT * CY_DELAY_MAX))) { 258 + dev_err(ts->dev, "timeout waiting for soft reset\n"); 259 + retval = -EIO; 260 + } 262 261 263 262 out: 264 263 ts->state = CY_IDLE_STATE; ··· 414 405 if (GET_BOOTLOADERMODE(ts->bl_data.bl_status) && 415 406 IS_VALID_APP(ts->bl_data.bl_status)) { 416 407 error = cyttsp_exit_bl_mode(ts); 417 - if (error) 408 + if (error) { 409 + dev_err(ts->dev, "failed to exit bootloader mode\n"); 418 410 return error; 411 + } 419 412 } 420 413 421 414 if (GET_HSTMODE(ts->bl_data.bl_file) != CY_OPERATE_MODE || ··· 640 629 return ERR_PTR(error); 641 630 642 631 init_completion(&ts->bl_ready); 643 - snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(dev)); 644 632 645 633 input_dev->name = "Cypress TTSP TouchScreen"; 646 - input_dev->phys = ts->phys; 647 634 input_dev->id.bustype = bus_ops->bustype; 648 635 input_dev->dev.parent = ts->dev; 649 636 ··· 652 643 653 644 input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_X); 654 645 input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_Y); 646 + /* One byte for width 0..255 so this is the limit */ 647 + input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); 648 + 655 649 touchscreen_parse_properties(input_dev, true, NULL); 656 650 657 - error = input_mt_init_slots(input_dev, CY_MAX_ID, 0); 651 + error = input_mt_init_slots(input_dev, CY_MAX_ID, INPUT_MT_DIRECT); 658 652 if (error) { 659 653 dev_err(dev, "Unable to init MT slots.\n"); 660 654 return ERR_PTR(error); 661 655 } 662 656 663 657 error = devm_request_threaded_irq(dev, ts->irq, NULL, cyttsp_irq, 664 - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 658 + IRQF_TRIGGER_FALLING | IRQF_ONESHOT | 659 + IRQF_NO_AUTOEN, 665 660 "cyttsp", ts); 666 661 if (error) { 667 662 dev_err(ts->dev, "failed to request IRQ %d, err: %d\n", 668 663 ts->irq, error); 669 664 return ERR_PTR(error); 670 665 } 671 - 672 - disable_irq(ts->irq); 673 666 674 667 cyttsp_hard_reset(ts); 675 668
-1
drivers/input/touchscreen/cyttsp_core.h
··· 114 114 struct device *dev; 115 115 int irq; 116 116 struct input_dev *input; 117 - char phys[32]; 118 117 const struct cyttsp_bus_ops *bus_ops; 119 118 struct cyttsp_bootloader_data bl_data; 120 119 struct cyttsp_sysinfo_data sysinfo_data;
+42 -2
drivers/input/touchscreen/elants_i2c.c
··· 38 38 #include <linux/of.h> 39 39 #include <linux/gpio/consumer.h> 40 40 #include <linux/regulator/consumer.h> 41 + #include <linux/uuid.h> 41 42 #include <asm/unaligned.h> 42 43 43 44 /* Device, Driver information */ ··· 1335 1334 } 1336 1335 } 1337 1336 1337 + #ifdef CONFIG_ACPI 1338 + static const struct acpi_device_id i2c_hid_ids[] = { 1339 + {"ACPI0C50", 0 }, 1340 + {"PNP0C50", 0 }, 1341 + { }, 1342 + }; 1343 + 1344 + static const guid_t i2c_hid_guid = 1345 + GUID_INIT(0x3CDFF6F7, 0x4267, 0x4555, 1346 + 0xAD, 0x05, 0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE); 1347 + 1348 + static bool elants_acpi_is_hid_device(struct device *dev) 1349 + { 1350 + acpi_handle handle = ACPI_HANDLE(dev); 1351 + union acpi_object *obj; 1352 + 1353 + if (acpi_match_device_ids(ACPI_COMPANION(dev), i2c_hid_ids)) 1354 + return false; 1355 + 1356 + obj = acpi_evaluate_dsm_typed(handle, &i2c_hid_guid, 1, 1, NULL, ACPI_TYPE_INTEGER); 1357 + if (obj) { 1358 + ACPI_FREE(obj); 1359 + return true; 1360 + } 1361 + 1362 + return false; 1363 + } 1364 + #else 1365 + static bool elants_acpi_is_hid_device(struct device *dev) 1366 + { 1367 + return false; 1368 + } 1369 + #endif 1370 + 1338 1371 static int elants_i2c_probe(struct i2c_client *client, 1339 1372 const struct i2c_device_id *id) 1340 1373 { ··· 1377 1342 unsigned long irqflags; 1378 1343 int error; 1379 1344 1345 + /* Don't bind to i2c-hid compatible devices, these are handled by the i2c-hid drv. */ 1346 + if (elants_acpi_is_hid_device(&client->dev)) { 1347 + dev_warn(&client->dev, "This device appears to be an I2C-HID device, not binding\n"); 1348 + return -ENODEV; 1349 + } 1350 + 1380 1351 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { 1381 - dev_err(&client->dev, 1382 - "%s: i2c check functionality error\n", DEVICE_NAME); 1352 + dev_err(&client->dev, "I2C check functionality error\n"); 1383 1353 return -ENXIO; 1384 1354 } 1385 1355
+151 -126
drivers/input/touchscreen/exc3000.c
··· 25 25 #define EXC3000_NUM_SLOTS 10 26 26 #define EXC3000_SLOTS_PER_FRAME 5 27 27 #define EXC3000_LEN_FRAME 66 28 + #define EXC3000_LEN_VENDOR_REQUEST 68 28 29 #define EXC3000_LEN_POINT 10 29 30 30 31 #define EXC3000_LEN_MODEL_NAME 16 31 32 #define EXC3000_LEN_FW_VERSION 16 32 33 34 + #define EXC3000_VENDOR_EVENT 0x03 33 35 #define EXC3000_MT1_EVENT 0x06 34 36 #define EXC3000_MT2_EVENT 0x18 35 37 ··· 78 76 u8 buf[2 * EXC3000_LEN_FRAME]; 79 77 struct completion wait_event; 80 78 struct mutex query_lock; 81 - int query_result; 82 - char model[EXC3000_LEN_MODEL_NAME]; 83 - char fw_version[EXC3000_LEN_FW_VERSION]; 84 79 }; 85 80 86 81 static void exc3000_report_slots(struct input_dev *input, ··· 104 105 input_sync(data->input); 105 106 } 106 107 108 + static inline void exc3000_schedule_timer(struct exc3000_data *data) 109 + { 110 + mod_timer(&data->timer, jiffies + msecs_to_jiffies(EXC3000_TIMEOUT_MS)); 111 + } 112 + 107 113 static int exc3000_read_frame(struct exc3000_data *data, u8 *buf) 108 114 { 109 115 struct i2c_client *client = data->client; 110 - u8 expected_event = EXC3000_MT1_EVENT; 111 116 int ret; 112 - 113 - if (data->info->max_xy == SZ_16K - 1) 114 - expected_event = EXC3000_MT2_EVENT; 115 117 116 118 ret = i2c_master_send(client, "'", 2); 117 119 if (ret < 0) ··· 131 131 if (get_unaligned_le16(buf) != EXC3000_LEN_FRAME) 132 132 return -EINVAL; 133 133 134 - if (buf[2] != expected_event) 135 - return -EINVAL; 136 - 137 134 return 0; 138 135 } 139 136 140 - static int exc3000_read_data(struct exc3000_data *data, 141 - u8 *buf, int *n_slots) 137 + static int exc3000_handle_mt_event(struct exc3000_data *data) 142 138 { 143 - int error; 139 + struct input_dev *input = data->input; 140 + int ret, total_slots; 141 + u8 *buf = data->buf; 144 142 145 - error = exc3000_read_frame(data, buf); 146 - if (error) 147 - return error; 143 + total_slots = buf[3]; 144 + if (!total_slots || total_slots > EXC3000_NUM_SLOTS) { 145 + ret = -EINVAL; 146 + goto out_fail; 147 + } 148 148 149 - *n_slots = buf[3]; 150 - if (!*n_slots || *n_slots > EXC3000_NUM_SLOTS) 151 - return -EINVAL; 152 - 153 - if (*n_slots > EXC3000_SLOTS_PER_FRAME) { 149 + if (total_slots > EXC3000_SLOTS_PER_FRAME) { 154 150 /* Read 2nd frame to get the rest of the contacts. */ 155 - error = exc3000_read_frame(data, buf + EXC3000_LEN_FRAME); 156 - if (error) 157 - return error; 151 + ret = exc3000_read_frame(data, buf + EXC3000_LEN_FRAME); 152 + if (ret) 153 + goto out_fail; 158 154 159 155 /* 2nd chunk must have number of contacts set to 0. */ 160 - if (buf[EXC3000_LEN_FRAME + 3] != 0) 161 - return -EINVAL; 162 - } 163 - 164 - return 0; 165 - } 166 - 167 - static int exc3000_query_interrupt(struct exc3000_data *data) 168 - { 169 - u8 *buf = data->buf; 170 - int error; 171 - 172 - error = i2c_master_recv(data->client, buf, EXC3000_LEN_FRAME); 173 - if (error < 0) 174 - return error; 175 - 176 - if (buf[0] != 'B') 177 - return -EPROTO; 178 - 179 - if (buf[4] == 'E') 180 - strlcpy(data->model, buf + 5, sizeof(data->model)); 181 - else if (buf[4] == 'D') 182 - strlcpy(data->fw_version, buf + 5, sizeof(data->fw_version)); 183 - else 184 - return -EPROTO; 185 - 186 - return 0; 187 - } 188 - 189 - static irqreturn_t exc3000_interrupt(int irq, void *dev_id) 190 - { 191 - struct exc3000_data *data = dev_id; 192 - struct input_dev *input = data->input; 193 - u8 *buf = data->buf; 194 - int slots, total_slots; 195 - int error; 196 - 197 - if (mutex_is_locked(&data->query_lock)) { 198 - data->query_result = exc3000_query_interrupt(data); 199 - complete(&data->wait_event); 200 - goto out; 201 - } 202 - 203 - error = exc3000_read_data(data, buf, &total_slots); 204 - if (error) { 205 - /* Schedule a timer to release "stuck" contacts */ 206 - mod_timer(&data->timer, 207 - jiffies + msecs_to_jiffies(EXC3000_TIMEOUT_MS)); 208 - goto out; 156 + if (buf[EXC3000_LEN_FRAME + 3] != 0) { 157 + ret = -EINVAL; 158 + goto out_fail; 159 + } 209 160 } 210 161 211 162 /* ··· 165 214 del_timer_sync(&data->timer); 166 215 167 216 while (total_slots > 0) { 168 - slots = min(total_slots, EXC3000_SLOTS_PER_FRAME); 217 + int slots = min(total_slots, EXC3000_SLOTS_PER_FRAME); 218 + 169 219 exc3000_report_slots(input, &data->prop, buf + 4, slots); 170 220 total_slots -= slots; 171 221 buf += EXC3000_LEN_FRAME; ··· 175 223 input_mt_sync_frame(input); 176 224 input_sync(input); 177 225 226 + return 0; 227 + 228 + out_fail: 229 + /* Schedule a timer to release "stuck" contacts */ 230 + exc3000_schedule_timer(data); 231 + 232 + return ret; 233 + } 234 + 235 + static irqreturn_t exc3000_interrupt(int irq, void *dev_id) 236 + { 237 + struct exc3000_data *data = dev_id; 238 + u8 *buf = data->buf; 239 + int ret; 240 + 241 + ret = exc3000_read_frame(data, buf); 242 + if (ret) { 243 + /* Schedule a timer to release "stuck" contacts */ 244 + exc3000_schedule_timer(data); 245 + goto out; 246 + } 247 + 248 + switch (buf[2]) { 249 + case EXC3000_VENDOR_EVENT: 250 + complete(&data->wait_event); 251 + break; 252 + 253 + case EXC3000_MT1_EVENT: 254 + case EXC3000_MT2_EVENT: 255 + exc3000_handle_mt_event(data); 256 + break; 257 + 258 + default: 259 + break; 260 + } 261 + 178 262 out: 179 263 return IRQ_HANDLED; 264 + } 265 + 266 + static int exc3000_vendor_data_request(struct exc3000_data *data, u8 *request, 267 + u8 request_len, u8 *response, int timeout) 268 + { 269 + u8 buf[EXC3000_LEN_VENDOR_REQUEST] = { 0x67, 0x00, 0x42, 0x00, 0x03 }; 270 + int ret; 271 + 272 + mutex_lock(&data->query_lock); 273 + 274 + reinit_completion(&data->wait_event); 275 + 276 + buf[5] = request_len; 277 + memcpy(&buf[6], request, request_len); 278 + 279 + ret = i2c_master_send(data->client, buf, EXC3000_LEN_VENDOR_REQUEST); 280 + if (ret < 0) 281 + goto out_unlock; 282 + 283 + if (response) { 284 + ret = wait_for_completion_timeout(&data->wait_event, 285 + timeout * HZ); 286 + if (ret <= 0) { 287 + ret = -ETIMEDOUT; 288 + goto out_unlock; 289 + } 290 + 291 + if (data->buf[3] >= EXC3000_LEN_FRAME) { 292 + ret = -ENOSPC; 293 + goto out_unlock; 294 + } 295 + 296 + memcpy(response, &data->buf[4], data->buf[3]); 297 + ret = data->buf[3]; 298 + } 299 + 300 + out_unlock: 301 + mutex_unlock(&data->query_lock); 302 + 303 + return ret; 180 304 } 181 305 182 306 static ssize_t fw_version_show(struct device *dev, ··· 260 232 { 261 233 struct i2c_client *client = to_i2c_client(dev); 262 234 struct exc3000_data *data = i2c_get_clientdata(client); 263 - static const u8 request[68] = { 264 - 0x67, 0x00, 0x42, 0x00, 0x03, 0x01, 'D', 0x00 265 - }; 266 - int error; 235 + u8 response[EXC3000_LEN_FRAME]; 236 + int ret; 267 237 268 - mutex_lock(&data->query_lock); 238 + /* query bootloader info */ 239 + ret = exc3000_vendor_data_request(data, 240 + (u8[]){0x39, 0x02}, 2, response, 1); 241 + if (ret < 0) 242 + return ret; 269 243 270 - data->query_result = -ETIMEDOUT; 271 - reinit_completion(&data->wait_event); 244 + /* 245 + * If the bootloader version is non-zero then the device is in 246 + * bootloader mode and won't answer a query for the application FW 247 + * version, so we just use the bootloader version info. 248 + */ 249 + if (response[2] || response[3]) 250 + return sprintf(buf, "%d.%d\n", response[2], response[3]); 272 251 273 - error = i2c_master_send(client, request, sizeof(request)); 274 - if (error < 0) { 275 - mutex_unlock(&data->query_lock); 276 - return error; 277 - } 252 + ret = exc3000_vendor_data_request(data, (u8[]){'D'}, 1, response, 1); 253 + if (ret < 0) 254 + return ret; 278 255 279 - wait_for_completion_interruptible_timeout(&data->wait_event, 1 * HZ); 280 - mutex_unlock(&data->query_lock); 281 - 282 - if (data->query_result < 0) 283 - return data->query_result; 284 - 285 - return sprintf(buf, "%s\n", data->fw_version); 256 + return sprintf(buf, "%s\n", &response[1]); 286 257 } 287 258 static DEVICE_ATTR_RO(fw_version); 288 - 289 - static ssize_t exc3000_get_model(struct exc3000_data *data) 290 - { 291 - static const u8 request[68] = { 292 - 0x67, 0x00, 0x42, 0x00, 0x03, 0x01, 'E', 0x00 293 - }; 294 - struct i2c_client *client = data->client; 295 - int error; 296 - 297 - mutex_lock(&data->query_lock); 298 - data->query_result = -ETIMEDOUT; 299 - reinit_completion(&data->wait_event); 300 - 301 - error = i2c_master_send(client, request, sizeof(request)); 302 - if (error < 0) { 303 - mutex_unlock(&data->query_lock); 304 - return error; 305 - } 306 - 307 - wait_for_completion_interruptible_timeout(&data->wait_event, 1 * HZ); 308 - mutex_unlock(&data->query_lock); 309 - 310 - return data->query_result; 311 - } 312 259 313 260 static ssize_t model_show(struct device *dev, 314 261 struct device_attribute *attr, char *buf) 315 262 { 316 263 struct i2c_client *client = to_i2c_client(dev); 317 264 struct exc3000_data *data = i2c_get_clientdata(client); 318 - int error; 265 + u8 response[EXC3000_LEN_FRAME]; 266 + int ret; 319 267 320 - error = exc3000_get_model(data); 321 - if (error < 0) 322 - return error; 268 + ret = exc3000_vendor_data_request(data, (u8[]){'E'}, 1, response, 1); 269 + if (ret < 0) 270 + return ret; 323 271 324 - return sprintf(buf, "%s\n", data->model); 272 + return sprintf(buf, "%s\n", &response[1]); 325 273 } 326 274 static DEVICE_ATTR_RO(model); 275 + 276 + static ssize_t type_show(struct device *dev, 277 + struct device_attribute *attr, char *buf) 278 + { 279 + struct i2c_client *client = to_i2c_client(dev); 280 + struct exc3000_data *data = i2c_get_clientdata(client); 281 + u8 response[EXC3000_LEN_FRAME]; 282 + int ret; 283 + 284 + ret = exc3000_vendor_data_request(data, (u8[]){'F'}, 1, response, 1); 285 + if (ret < 0) 286 + return ret; 287 + 288 + return sprintf(buf, "%s\n", &response[1]); 289 + } 290 + static DEVICE_ATTR_RO(type); 327 291 328 292 static struct attribute *sysfs_attrs[] = { 329 293 &dev_attr_fw_version.attr, 330 294 &dev_attr_model.attr, 295 + &dev_attr_type.attr, 331 296 NULL 332 297 }; 333 298 ··· 400 379 * or two touch events anyways). 401 380 */ 402 381 for (retry = 0; retry < 3; retry++) { 403 - error = exc3000_get_model(data); 404 - if (!error) 382 + u8 response[EXC3000_LEN_FRAME]; 383 + 384 + error = exc3000_vendor_data_request(data, (u8[]){'E'}, 1, 385 + response, 1); 386 + if (error > 0) { 387 + dev_dbg(&client->dev, "TS Model: %s", &response[1]); 388 + error = 0; 405 389 break; 390 + } 406 391 dev_warn(&client->dev, "Retry %d get EETI EXC3000 model: %d\n", 407 392 retry + 1, error); 408 393 } 409 394 410 395 if (error) 411 396 return error; 412 - 413 - dev_dbg(&client->dev, "TS Model: %s", data->model); 414 397 415 398 i2c_set_clientdata(client, data); 416 399
+591
drivers/input/touchscreen/hycon-hy46xx.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Copyright (C) 2021 4 + * Author(s): Giulio Benetti <giulio.benetti@benettiengineering.com> 5 + */ 6 + 7 + #include <linux/delay.h> 8 + #include <linux/gpio/consumer.h> 9 + #include <linux/i2c.h> 10 + #include <linux/interrupt.h> 11 + #include <linux/input.h> 12 + #include <linux/input/mt.h> 13 + #include <linux/input/touchscreen.h> 14 + #include <linux/irq.h> 15 + #include <linux/regulator/consumer.h> 16 + #include <linux/regmap.h> 17 + 18 + #include <asm/unaligned.h> 19 + 20 + #define HY46XX_CHKSUM_CODE 0x1 21 + #define HY46XX_FINGER_NUM 0x2 22 + #define HY46XX_CHKSUM_LEN 0x7 23 + #define HY46XX_THRESHOLD 0x80 24 + #define HY46XX_GLOVE_EN 0x84 25 + #define HY46XX_REPORT_SPEED 0x88 26 + #define HY46XX_PWR_NOISE_EN 0x89 27 + #define HY46XX_FILTER_DATA 0x8A 28 + #define HY46XX_GAIN 0x92 29 + #define HY46XX_EDGE_OFFSET 0x93 30 + #define HY46XX_RX_NR_USED 0x94 31 + #define HY46XX_TX_NR_USED 0x95 32 + #define HY46XX_PWR_MODE 0xA5 33 + #define HY46XX_FW_VERSION 0xA6 34 + #define HY46XX_LIB_VERSION 0xA7 35 + #define HY46XX_TP_INFO 0xA8 36 + #define HY46XX_TP_CHIP_ID 0xA9 37 + #define HY46XX_BOOT_VER 0xB0 38 + 39 + #define HY46XX_TPLEN 0x6 40 + #define HY46XX_REPORT_PKT_LEN 0x44 41 + 42 + #define HY46XX_MAX_SUPPORTED_POINTS 11 43 + 44 + #define TOUCH_EVENT_DOWN 0x00 45 + #define TOUCH_EVENT_UP 0x01 46 + #define TOUCH_EVENT_CONTACT 0x02 47 + #define TOUCH_EVENT_RESERVED 0x03 48 + 49 + struct hycon_hy46xx_data { 50 + struct i2c_client *client; 51 + struct input_dev *input; 52 + struct touchscreen_properties prop; 53 + struct regulator *vcc; 54 + 55 + struct gpio_desc *reset_gpio; 56 + 57 + struct mutex mutex; 58 + struct regmap *regmap; 59 + 60 + int threshold; 61 + bool glove_enable; 62 + int report_speed; 63 + bool noise_filter_enable; 64 + int filter_data; 65 + int gain; 66 + int edge_offset; 67 + int rx_number_used; 68 + int tx_number_used; 69 + int power_mode; 70 + int fw_version; 71 + int lib_version; 72 + int tp_information; 73 + int tp_chip_id; 74 + int bootloader_version; 75 + }; 76 + 77 + static const struct regmap_config hycon_hy46xx_i2c_regmap_config = { 78 + .reg_bits = 8, 79 + .val_bits = 8, 80 + }; 81 + 82 + static bool hycon_hy46xx_check_checksum(struct hycon_hy46xx_data *tsdata, u8 *buf) 83 + { 84 + u8 chksum = 0; 85 + int i; 86 + 87 + for (i = 2; i < buf[HY46XX_CHKSUM_LEN]; i++) 88 + chksum += buf[i]; 89 + 90 + if (chksum == buf[HY46XX_CHKSUM_CODE]) 91 + return true; 92 + 93 + dev_err_ratelimited(&tsdata->client->dev, 94 + "checksum error: 0x%02x expected, got 0x%02x\n", 95 + chksum, buf[HY46XX_CHKSUM_CODE]); 96 + 97 + return false; 98 + } 99 + 100 + static irqreturn_t hycon_hy46xx_isr(int irq, void *dev_id) 101 + { 102 + struct hycon_hy46xx_data *tsdata = dev_id; 103 + struct device *dev = &tsdata->client->dev; 104 + u8 rdbuf[HY46XX_REPORT_PKT_LEN]; 105 + int i, x, y, id; 106 + int error; 107 + 108 + memset(rdbuf, 0, sizeof(rdbuf)); 109 + 110 + error = regmap_bulk_read(tsdata->regmap, 0, rdbuf, sizeof(rdbuf)); 111 + if (error) { 112 + dev_err_ratelimited(dev, "Unable to fetch data, error: %d\n", 113 + error); 114 + goto out; 115 + } 116 + 117 + if (!hycon_hy46xx_check_checksum(tsdata, rdbuf)) 118 + goto out; 119 + 120 + for (i = 0; i < HY46XX_MAX_SUPPORTED_POINTS; i++) { 121 + u8 *buf = &rdbuf[3 + (HY46XX_TPLEN * i)]; 122 + int type = buf[0] >> 6; 123 + 124 + if (type == TOUCH_EVENT_RESERVED) 125 + continue; 126 + 127 + x = get_unaligned_be16(buf) & 0x0fff; 128 + y = get_unaligned_be16(buf + 2) & 0x0fff; 129 + 130 + id = buf[2] >> 4; 131 + 132 + input_mt_slot(tsdata->input, id); 133 + if (input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, 134 + type != TOUCH_EVENT_UP)) 135 + touchscreen_report_pos(tsdata->input, &tsdata->prop, 136 + x, y, true); 137 + } 138 + 139 + input_mt_report_pointer_emulation(tsdata->input, false); 140 + input_sync(tsdata->input); 141 + 142 + out: 143 + return IRQ_HANDLED; 144 + } 145 + 146 + struct hycon_hy46xx_attribute { 147 + struct device_attribute dattr; 148 + size_t field_offset; 149 + u8 address; 150 + u8 limit_low; 151 + u8 limit_high; 152 + }; 153 + 154 + #define HYCON_ATTR_U8(_field, _mode, _address, _limit_low, _limit_high) \ 155 + struct hycon_hy46xx_attribute hycon_hy46xx_attr_##_field = { \ 156 + .dattr = __ATTR(_field, _mode, \ 157 + hycon_hy46xx_setting_show, \ 158 + hycon_hy46xx_setting_store), \ 159 + .field_offset = offsetof(struct hycon_hy46xx_data, _field), \ 160 + .address = _address, \ 161 + .limit_low = _limit_low, \ 162 + .limit_high = _limit_high, \ 163 + } 164 + 165 + #define HYCON_ATTR_BOOL(_field, _mode, _address) \ 166 + struct hycon_hy46xx_attribute hycon_hy46xx_attr_##_field = { \ 167 + .dattr = __ATTR(_field, _mode, \ 168 + hycon_hy46xx_setting_show, \ 169 + hycon_hy46xx_setting_store), \ 170 + .field_offset = offsetof(struct hycon_hy46xx_data, _field), \ 171 + .address = _address, \ 172 + .limit_low = false, \ 173 + .limit_high = true, \ 174 + } 175 + 176 + static ssize_t hycon_hy46xx_setting_show(struct device *dev, 177 + struct device_attribute *dattr, char *buf) 178 + { 179 + struct i2c_client *client = to_i2c_client(dev); 180 + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); 181 + struct hycon_hy46xx_attribute *attr = 182 + container_of(dattr, struct hycon_hy46xx_attribute, dattr); 183 + u8 *field = (u8 *)tsdata + attr->field_offset; 184 + size_t count = 0; 185 + int error = 0; 186 + int val; 187 + 188 + mutex_lock(&tsdata->mutex); 189 + 190 + error = regmap_read(tsdata->regmap, attr->address, &val); 191 + if (error < 0) { 192 + dev_err(&tsdata->client->dev, 193 + "Failed to fetch attribute %s, error %d\n", 194 + dattr->attr.name, error); 195 + goto out; 196 + } 197 + 198 + if (val != *field) { 199 + dev_warn(&tsdata->client->dev, 200 + "%s: read (%d) and stored value (%d) differ\n", 201 + dattr->attr.name, val, *field); 202 + *field = val; 203 + } 204 + 205 + count = scnprintf(buf, PAGE_SIZE, "%d\n", val); 206 + 207 + out: 208 + mutex_unlock(&tsdata->mutex); 209 + return error ?: count; 210 + } 211 + 212 + static ssize_t hycon_hy46xx_setting_store(struct device *dev, 213 + struct device_attribute *dattr, 214 + const char *buf, size_t count) 215 + { 216 + struct i2c_client *client = to_i2c_client(dev); 217 + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); 218 + struct hycon_hy46xx_attribute *attr = 219 + container_of(dattr, struct hycon_hy46xx_attribute, dattr); 220 + u8 *field = (u8 *)tsdata + attr->field_offset; 221 + unsigned int val; 222 + int error; 223 + 224 + mutex_lock(&tsdata->mutex); 225 + 226 + error = kstrtouint(buf, 0, &val); 227 + if (error) 228 + goto out; 229 + 230 + if (val < attr->limit_low || val > attr->limit_high) { 231 + error = -ERANGE; 232 + goto out; 233 + } 234 + 235 + error = regmap_write(tsdata->regmap, attr->address, val); 236 + if (error < 0) { 237 + dev_err(&tsdata->client->dev, 238 + "Failed to update attribute %s, error: %d\n", 239 + dattr->attr.name, error); 240 + goto out; 241 + } 242 + *field = val; 243 + 244 + out: 245 + mutex_unlock(&tsdata->mutex); 246 + return error ?: count; 247 + } 248 + 249 + static HYCON_ATTR_U8(threshold, 0644, HY46XX_THRESHOLD, 0, 255); 250 + static HYCON_ATTR_BOOL(glove_enable, 0644, HY46XX_GLOVE_EN); 251 + static HYCON_ATTR_U8(report_speed, 0644, HY46XX_REPORT_SPEED, 0, 255); 252 + static HYCON_ATTR_BOOL(noise_filter_enable, 0644, HY46XX_PWR_NOISE_EN); 253 + static HYCON_ATTR_U8(filter_data, 0644, HY46XX_FILTER_DATA, 0, 5); 254 + static HYCON_ATTR_U8(gain, 0644, HY46XX_GAIN, 0, 5); 255 + static HYCON_ATTR_U8(edge_offset, 0644, HY46XX_EDGE_OFFSET, 0, 5); 256 + static HYCON_ATTR_U8(fw_version, 0444, HY46XX_FW_VERSION, 0, 255); 257 + static HYCON_ATTR_U8(lib_version, 0444, HY46XX_LIB_VERSION, 0, 255); 258 + static HYCON_ATTR_U8(tp_information, 0444, HY46XX_TP_INFO, 0, 255); 259 + static HYCON_ATTR_U8(tp_chip_id, 0444, HY46XX_TP_CHIP_ID, 0, 255); 260 + static HYCON_ATTR_U8(bootloader_version, 0444, HY46XX_BOOT_VER, 0, 255); 261 + 262 + static struct attribute *hycon_hy46xx_attrs[] = { 263 + &hycon_hy46xx_attr_threshold.dattr.attr, 264 + &hycon_hy46xx_attr_glove_enable.dattr.attr, 265 + &hycon_hy46xx_attr_report_speed.dattr.attr, 266 + &hycon_hy46xx_attr_noise_filter_enable.dattr.attr, 267 + &hycon_hy46xx_attr_filter_data.dattr.attr, 268 + &hycon_hy46xx_attr_gain.dattr.attr, 269 + &hycon_hy46xx_attr_edge_offset.dattr.attr, 270 + &hycon_hy46xx_attr_fw_version.dattr.attr, 271 + &hycon_hy46xx_attr_lib_version.dattr.attr, 272 + &hycon_hy46xx_attr_tp_information.dattr.attr, 273 + &hycon_hy46xx_attr_tp_chip_id.dattr.attr, 274 + &hycon_hy46xx_attr_bootloader_version.dattr.attr, 275 + NULL 276 + }; 277 + 278 + static const struct attribute_group hycon_hy46xx_attr_group = { 279 + .attrs = hycon_hy46xx_attrs, 280 + }; 281 + 282 + static void hycon_hy46xx_get_defaults(struct device *dev, struct hycon_hy46xx_data *tsdata) 283 + { 284 + bool val_bool; 285 + int error; 286 + u32 val; 287 + 288 + error = device_property_read_u32(dev, "hycon,threshold", &val); 289 + if (!error) { 290 + error = regmap_write(tsdata->regmap, HY46XX_THRESHOLD, val); 291 + if (error < 0) 292 + goto out; 293 + 294 + tsdata->threshold = val; 295 + } 296 + 297 + val_bool = device_property_read_bool(dev, "hycon,glove-enable"); 298 + error = regmap_write(tsdata->regmap, HY46XX_GLOVE_EN, val_bool); 299 + if (error < 0) 300 + goto out; 301 + tsdata->glove_enable = val_bool; 302 + 303 + error = device_property_read_u32(dev, "hycon,report-speed-hz", &val); 304 + if (!error) { 305 + error = regmap_write(tsdata->regmap, HY46XX_REPORT_SPEED, val); 306 + if (error < 0) 307 + goto out; 308 + 309 + tsdata->report_speed = val; 310 + } 311 + 312 + val_bool = device_property_read_bool(dev, "hycon,noise-filter-enable"); 313 + error = regmap_write(tsdata->regmap, HY46XX_PWR_NOISE_EN, val_bool); 314 + if (error < 0) 315 + goto out; 316 + tsdata->noise_filter_enable = val_bool; 317 + 318 + error = device_property_read_u32(dev, "hycon,filter-data", &val); 319 + if (!error) { 320 + error = regmap_write(tsdata->regmap, HY46XX_FILTER_DATA, val); 321 + if (error < 0) 322 + goto out; 323 + 324 + tsdata->filter_data = val; 325 + } 326 + 327 + error = device_property_read_u32(dev, "hycon,gain", &val); 328 + if (!error) { 329 + error = regmap_write(tsdata->regmap, HY46XX_GAIN, val); 330 + if (error < 0) 331 + goto out; 332 + 333 + tsdata->gain = val; 334 + } 335 + 336 + error = device_property_read_u32(dev, "hycon,edge-offset", &val); 337 + if (!error) { 338 + error = regmap_write(tsdata->regmap, HY46XX_EDGE_OFFSET, val); 339 + if (error < 0) 340 + goto out; 341 + 342 + tsdata->edge_offset = val; 343 + } 344 + 345 + return; 346 + out: 347 + dev_err(&tsdata->client->dev, "Failed to set default settings"); 348 + } 349 + 350 + static void hycon_hy46xx_get_parameters(struct hycon_hy46xx_data *tsdata) 351 + { 352 + int error; 353 + u32 val; 354 + 355 + error = regmap_read(tsdata->regmap, HY46XX_THRESHOLD, &val); 356 + if (error < 0) 357 + goto out; 358 + tsdata->threshold = val; 359 + 360 + error = regmap_read(tsdata->regmap, HY46XX_GLOVE_EN, &val); 361 + if (error < 0) 362 + goto out; 363 + tsdata->glove_enable = val; 364 + 365 + error = regmap_read(tsdata->regmap, HY46XX_REPORT_SPEED, &val); 366 + if (error < 0) 367 + goto out; 368 + tsdata->report_speed = val; 369 + 370 + error = regmap_read(tsdata->regmap, HY46XX_PWR_NOISE_EN, &val); 371 + if (error < 0) 372 + goto out; 373 + tsdata->noise_filter_enable = val; 374 + 375 + error = regmap_read(tsdata->regmap, HY46XX_FILTER_DATA, &val); 376 + if (error < 0) 377 + goto out; 378 + tsdata->filter_data = val; 379 + 380 + error = regmap_read(tsdata->regmap, HY46XX_GAIN, &val); 381 + if (error < 0) 382 + goto out; 383 + tsdata->gain = val; 384 + 385 + error = regmap_read(tsdata->regmap, HY46XX_EDGE_OFFSET, &val); 386 + if (error < 0) 387 + goto out; 388 + tsdata->edge_offset = val; 389 + 390 + error = regmap_read(tsdata->regmap, HY46XX_RX_NR_USED, &val); 391 + if (error < 0) 392 + goto out; 393 + tsdata->rx_number_used = val; 394 + 395 + error = regmap_read(tsdata->regmap, HY46XX_TX_NR_USED, &val); 396 + if (error < 0) 397 + goto out; 398 + tsdata->tx_number_used = val; 399 + 400 + error = regmap_read(tsdata->regmap, HY46XX_PWR_MODE, &val); 401 + if (error < 0) 402 + goto out; 403 + tsdata->power_mode = val; 404 + 405 + error = regmap_read(tsdata->regmap, HY46XX_FW_VERSION, &val); 406 + if (error < 0) 407 + goto out; 408 + tsdata->fw_version = val; 409 + 410 + error = regmap_read(tsdata->regmap, HY46XX_LIB_VERSION, &val); 411 + if (error < 0) 412 + goto out; 413 + tsdata->lib_version = val; 414 + 415 + error = regmap_read(tsdata->regmap, HY46XX_TP_INFO, &val); 416 + if (error < 0) 417 + goto out; 418 + tsdata->tp_information = val; 419 + 420 + error = regmap_read(tsdata->regmap, HY46XX_TP_CHIP_ID, &val); 421 + if (error < 0) 422 + goto out; 423 + tsdata->tp_chip_id = val; 424 + 425 + error = regmap_read(tsdata->regmap, HY46XX_BOOT_VER, &val); 426 + if (error < 0) 427 + goto out; 428 + tsdata->bootloader_version = val; 429 + 430 + return; 431 + out: 432 + dev_err(&tsdata->client->dev, "Failed to read default settings"); 433 + } 434 + 435 + static void hycon_hy46xx_disable_regulator(void *arg) 436 + { 437 + struct hycon_hy46xx_data *data = arg; 438 + 439 + regulator_disable(data->vcc); 440 + } 441 + 442 + static int hycon_hy46xx_probe(struct i2c_client *client, 443 + const struct i2c_device_id *id) 444 + { 445 + struct hycon_hy46xx_data *tsdata; 446 + struct input_dev *input; 447 + int error; 448 + 449 + dev_dbg(&client->dev, "probing for HYCON HY46XX I2C\n"); 450 + 451 + tsdata = devm_kzalloc(&client->dev, sizeof(*tsdata), GFP_KERNEL); 452 + if (!tsdata) 453 + return -ENOMEM; 454 + 455 + tsdata->vcc = devm_regulator_get(&client->dev, "vcc"); 456 + if (IS_ERR(tsdata->vcc)) { 457 + error = PTR_ERR(tsdata->vcc); 458 + if (error != -EPROBE_DEFER) 459 + dev_err(&client->dev, 460 + "failed to request regulator: %d\n", error); 461 + return error; 462 + } 463 + 464 + error = regulator_enable(tsdata->vcc); 465 + if (error < 0) { 466 + dev_err(&client->dev, "failed to enable vcc: %d\n", error); 467 + return error; 468 + } 469 + 470 + error = devm_add_action_or_reset(&client->dev, 471 + hycon_hy46xx_disable_regulator, 472 + tsdata); 473 + if (error) 474 + return error; 475 + 476 + tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev, 477 + "reset", GPIOD_OUT_LOW); 478 + if (IS_ERR(tsdata->reset_gpio)) { 479 + error = PTR_ERR(tsdata->reset_gpio); 480 + dev_err(&client->dev, 481 + "Failed to request GPIO reset pin, error %d\n", error); 482 + return error; 483 + } 484 + 485 + if (tsdata->reset_gpio) { 486 + usleep_range(5000, 6000); 487 + gpiod_set_value_cansleep(tsdata->reset_gpio, 1); 488 + usleep_range(5000, 6000); 489 + gpiod_set_value_cansleep(tsdata->reset_gpio, 0); 490 + msleep(1000); 491 + } 492 + 493 + input = devm_input_allocate_device(&client->dev); 494 + if (!input) { 495 + dev_err(&client->dev, "failed to allocate input device.\n"); 496 + return -ENOMEM; 497 + } 498 + 499 + mutex_init(&tsdata->mutex); 500 + tsdata->client = client; 501 + tsdata->input = input; 502 + 503 + tsdata->regmap = devm_regmap_init_i2c(client, 504 + &hycon_hy46xx_i2c_regmap_config); 505 + if (IS_ERR(tsdata->regmap)) { 506 + dev_err(&client->dev, "regmap allocation failed\n"); 507 + return PTR_ERR(tsdata->regmap); 508 + } 509 + 510 + hycon_hy46xx_get_defaults(&client->dev, tsdata); 511 + hycon_hy46xx_get_parameters(tsdata); 512 + 513 + input->name = "Hycon Capacitive Touch"; 514 + input->id.bustype = BUS_I2C; 515 + input->dev.parent = &client->dev; 516 + 517 + input_set_abs_params(input, ABS_MT_POSITION_X, 0, -1, 0, 0); 518 + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, -1, 0, 0); 519 + 520 + touchscreen_parse_properties(input, true, &tsdata->prop); 521 + 522 + error = input_mt_init_slots(input, HY46XX_MAX_SUPPORTED_POINTS, 523 + INPUT_MT_DIRECT); 524 + if (error) { 525 + dev_err(&client->dev, "Unable to init MT slots.\n"); 526 + return error; 527 + } 528 + 529 + i2c_set_clientdata(client, tsdata); 530 + 531 + error = devm_request_threaded_irq(&client->dev, client->irq, 532 + NULL, hycon_hy46xx_isr, IRQF_ONESHOT, 533 + client->name, tsdata); 534 + if (error) { 535 + dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); 536 + return error; 537 + } 538 + 539 + error = devm_device_add_group(&client->dev, &hycon_hy46xx_attr_group); 540 + if (error) 541 + return error; 542 + 543 + error = input_register_device(input); 544 + if (error) 545 + return error; 546 + 547 + dev_dbg(&client->dev, 548 + "HYCON HY46XX initialized: IRQ %d, Reset pin %d.\n", 549 + client->irq, 550 + tsdata->reset_gpio ? desc_to_gpio(tsdata->reset_gpio) : -1); 551 + 552 + return 0; 553 + } 554 + 555 + static const struct i2c_device_id hycon_hy46xx_id[] = { 556 + { .name = "hy4613" }, 557 + { .name = "hy4614" }, 558 + { .name = "hy4621" }, 559 + { .name = "hy4623" }, 560 + { .name = "hy4633" }, 561 + { .name = "hy4635" }, 562 + { /* sentinel */ } 563 + }; 564 + MODULE_DEVICE_TABLE(i2c, hycon_hy46xx_id); 565 + 566 + static const struct of_device_id hycon_hy46xx_of_match[] = { 567 + { .compatible = "hycon,hy4613" }, 568 + { .compatible = "hycon,hy4614" }, 569 + { .compatible = "hycon,hy4621" }, 570 + { .compatible = "hycon,hy4623" }, 571 + { .compatible = "hycon,hy4633" }, 572 + { .compatible = "hycon,hy4635" }, 573 + { /* sentinel */ } 574 + }; 575 + MODULE_DEVICE_TABLE(of, hycon_hy46xx_of_match); 576 + 577 + static struct i2c_driver hycon_hy46xx_driver = { 578 + .driver = { 579 + .name = "hycon_hy46xx", 580 + .of_match_table = hycon_hy46xx_of_match, 581 + .probe_type = PROBE_PREFER_ASYNCHRONOUS, 582 + }, 583 + .id_table = hycon_hy46xx_id, 584 + .probe = hycon_hy46xx_probe, 585 + }; 586 + 587 + module_i2c_driver(hycon_hy46xx_driver); 588 + 589 + MODULE_AUTHOR("Giulio Benetti <giulio.benetti@benettiengineering.com>"); 590 + MODULE_DESCRIPTION("HYCON HY46XX I2C Touchscreen Driver"); 591 + MODULE_LICENSE("GPL v2");
+1 -1
drivers/input/touchscreen/ili210x.c
··· 87 87 unsigned int *x, unsigned int *y, 88 88 unsigned int *z) 89 89 { 90 - if (touchdata[0] & BIT(finger)) 90 + if (!(touchdata[0] & BIT(finger))) 91 91 return false; 92 92 93 93 *x = get_unaligned_be16(touchdata + 1 + (finger * 4) + 0);
+690
drivers/input/touchscreen/ilitek_ts_i2c.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * ILITEK Touch IC driver for 23XX, 25XX and Lego series 4 + * 5 + * Copyright (C) 2011 ILI Technology Corporation. 6 + * Copyright (C) 2020 Luca Hsu <luca_hsu@ilitek.com> 7 + * Copyright (C) 2021 Joe Hung <joe_hung@ilitek.com> 8 + */ 9 + 10 + #include <linux/kernel.h> 11 + #include <linux/module.h> 12 + #include <linux/input.h> 13 + #include <linux/input/mt.h> 14 + #include <linux/i2c.h> 15 + #include <linux/slab.h> 16 + #include <linux/delay.h> 17 + #include <linux/interrupt.h> 18 + #include <linux/gpio.h> 19 + #include <linux/gpio/consumer.h> 20 + #include <linux/errno.h> 21 + #include <linux/acpi.h> 22 + #include <linux/input/touchscreen.h> 23 + #include <asm/unaligned.h> 24 + 25 + 26 + #define ILITEK_TS_NAME "ilitek_ts" 27 + #define BL_V1_8 0x108 28 + #define BL_V1_7 0x107 29 + #define BL_V1_6 0x106 30 + 31 + #define ILITEK_TP_CMD_GET_TP_RES 0x20 32 + #define ILITEK_TP_CMD_GET_SCRN_RES 0x21 33 + #define ILITEK_TP_CMD_SET_IC_SLEEP 0x30 34 + #define ILITEK_TP_CMD_SET_IC_WAKE 0x31 35 + #define ILITEK_TP_CMD_GET_FW_VER 0x40 36 + #define ILITEK_TP_CMD_GET_PRL_VER 0x42 37 + #define ILITEK_TP_CMD_GET_MCU_VER 0x61 38 + #define ILITEK_TP_CMD_GET_IC_MODE 0xC0 39 + 40 + #define REPORT_COUNT_ADDRESS 61 41 + #define ILITEK_SUPPORT_MAX_POINT 40 42 + 43 + struct ilitek_protocol_info { 44 + u16 ver; 45 + u8 ver_major; 46 + }; 47 + 48 + struct ilitek_ts_data { 49 + struct i2c_client *client; 50 + struct gpio_desc *reset_gpio; 51 + struct input_dev *input_dev; 52 + struct touchscreen_properties prop; 53 + 54 + const struct ilitek_protocol_map *ptl_cb_func; 55 + struct ilitek_protocol_info ptl; 56 + 57 + char product_id[30]; 58 + u16 mcu_ver; 59 + u8 ic_mode; 60 + u8 firmware_ver[8]; 61 + 62 + s32 reset_time; 63 + s32 screen_max_x; 64 + s32 screen_max_y; 65 + s32 screen_min_x; 66 + s32 screen_min_y; 67 + s32 max_tp; 68 + }; 69 + 70 + struct ilitek_protocol_map { 71 + u16 cmd; 72 + const char *name; 73 + int (*func)(struct ilitek_ts_data *ts, u16 cmd, u8 *inbuf, u8 *outbuf); 74 + }; 75 + 76 + enum ilitek_cmds { 77 + /* common cmds */ 78 + GET_PTL_VER = 0, 79 + GET_FW_VER, 80 + GET_SCRN_RES, 81 + GET_TP_RES, 82 + GET_IC_MODE, 83 + GET_MCU_VER, 84 + SET_IC_SLEEP, 85 + SET_IC_WAKE, 86 + 87 + /* ALWAYS keep at the end */ 88 + MAX_CMD_CNT 89 + }; 90 + 91 + /* ILITEK I2C R/W APIs */ 92 + static int ilitek_i2c_write_and_read(struct ilitek_ts_data *ts, 93 + u8 *cmd, int write_len, int delay, 94 + u8 *data, int read_len) 95 + { 96 + int error; 97 + struct i2c_client *client = ts->client; 98 + struct i2c_msg msgs[] = { 99 + { 100 + .addr = client->addr, 101 + .flags = 0, 102 + .len = write_len, 103 + .buf = cmd, 104 + }, 105 + { 106 + .addr = client->addr, 107 + .flags = I2C_M_RD, 108 + .len = read_len, 109 + .buf = data, 110 + }, 111 + }; 112 + 113 + if (delay == 0 && write_len > 0 && read_len > 0) { 114 + error = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); 115 + if (error < 0) 116 + return error; 117 + } else { 118 + if (write_len > 0) { 119 + error = i2c_transfer(client->adapter, msgs, 1); 120 + if (error < 0) 121 + return error; 122 + } 123 + if (delay > 0) 124 + mdelay(delay); 125 + 126 + if (read_len > 0) { 127 + error = i2c_transfer(client->adapter, msgs + 1, 1); 128 + if (error < 0) 129 + return error; 130 + } 131 + } 132 + 133 + return 0; 134 + } 135 + 136 + /* ILITEK ISR APIs */ 137 + static void ilitek_touch_down(struct ilitek_ts_data *ts, unsigned int id, 138 + unsigned int x, unsigned int y) 139 + { 140 + struct input_dev *input = ts->input_dev; 141 + 142 + input_mt_slot(input, id); 143 + input_mt_report_slot_state(input, MT_TOOL_FINGER, true); 144 + 145 + touchscreen_report_pos(input, &ts->prop, x, y, true); 146 + } 147 + 148 + static int ilitek_process_and_report_v6(struct ilitek_ts_data *ts) 149 + { 150 + int error = 0; 151 + u8 buf[512]; 152 + int packet_len = 5; 153 + int packet_max_point = 10; 154 + int report_max_point; 155 + int i, count; 156 + struct input_dev *input = ts->input_dev; 157 + struct device *dev = &ts->client->dev; 158 + unsigned int x, y, status, id; 159 + 160 + error = ilitek_i2c_write_and_read(ts, NULL, 0, 0, buf, 64); 161 + if (error) { 162 + dev_err(dev, "get touch info failed, err:%d\n", error); 163 + goto err_sync_frame; 164 + } 165 + 166 + report_max_point = buf[REPORT_COUNT_ADDRESS]; 167 + if (report_max_point > ts->max_tp) { 168 + dev_err(dev, "FW report max point:%d > panel info. max:%d\n", 169 + report_max_point, ts->max_tp); 170 + error = -EINVAL; 171 + goto err_sync_frame; 172 + } 173 + 174 + count = DIV_ROUND_UP(report_max_point, packet_max_point); 175 + for (i = 1; i < count; i++) { 176 + error = ilitek_i2c_write_and_read(ts, NULL, 0, 0, 177 + buf + i * 64, 64); 178 + if (error) { 179 + dev_err(dev, "get touch info. failed, cnt:%d, err:%d\n", 180 + count, error); 181 + goto err_sync_frame; 182 + } 183 + } 184 + 185 + for (i = 0; i < report_max_point; i++) { 186 + status = buf[i * packet_len + 1] & 0x40; 187 + if (!status) 188 + continue; 189 + 190 + id = buf[i * packet_len + 1] & 0x3F; 191 + 192 + x = get_unaligned_le16(buf + i * packet_len + 2); 193 + y = get_unaligned_le16(buf + i * packet_len + 4); 194 + 195 + if (x > ts->screen_max_x || x < ts->screen_min_x || 196 + y > ts->screen_max_y || y < ts->screen_min_y) { 197 + dev_warn(dev, "invalid position, X[%d,%u,%d], Y[%d,%u,%d]\n", 198 + ts->screen_min_x, x, ts->screen_max_x, 199 + ts->screen_min_y, y, ts->screen_max_y); 200 + continue; 201 + } 202 + 203 + ilitek_touch_down(ts, id, x, y); 204 + } 205 + 206 + err_sync_frame: 207 + input_mt_sync_frame(input); 208 + input_sync(input); 209 + return error; 210 + } 211 + 212 + /* APIs of cmds for ILITEK Touch IC */ 213 + static int api_protocol_set_cmd(struct ilitek_ts_data *ts, 214 + u16 idx, u8 *inbuf, u8 *outbuf) 215 + { 216 + u16 cmd; 217 + int error; 218 + 219 + if (idx >= MAX_CMD_CNT) 220 + return -EINVAL; 221 + 222 + cmd = ts->ptl_cb_func[idx].cmd; 223 + error = ts->ptl_cb_func[idx].func(ts, cmd, inbuf, outbuf); 224 + if (error) 225 + return error; 226 + 227 + return 0; 228 + } 229 + 230 + static int api_protocol_get_ptl_ver(struct ilitek_ts_data *ts, 231 + u16 cmd, u8 *inbuf, u8 *outbuf) 232 + { 233 + int error; 234 + u8 buf[64]; 235 + 236 + buf[0] = cmd; 237 + error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 3); 238 + if (error) 239 + return error; 240 + 241 + ts->ptl.ver = get_unaligned_be16(outbuf); 242 + ts->ptl.ver_major = outbuf[0]; 243 + 244 + return 0; 245 + } 246 + 247 + static int api_protocol_get_mcu_ver(struct ilitek_ts_data *ts, 248 + u16 cmd, u8 *inbuf, u8 *outbuf) 249 + { 250 + int error; 251 + u8 buf[64]; 252 + 253 + buf[0] = cmd; 254 + error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 32); 255 + if (error) 256 + return error; 257 + 258 + ts->mcu_ver = get_unaligned_le16(outbuf); 259 + memset(ts->product_id, 0, sizeof(ts->product_id)); 260 + memcpy(ts->product_id, outbuf + 6, 26); 261 + 262 + return 0; 263 + } 264 + 265 + static int api_protocol_get_fw_ver(struct ilitek_ts_data *ts, 266 + u16 cmd, u8 *inbuf, u8 *outbuf) 267 + { 268 + int error; 269 + u8 buf[64]; 270 + 271 + buf[0] = cmd; 272 + error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 8); 273 + if (error) 274 + return error; 275 + 276 + memcpy(ts->firmware_ver, outbuf, 8); 277 + 278 + return 0; 279 + } 280 + 281 + static int api_protocol_get_scrn_res(struct ilitek_ts_data *ts, 282 + u16 cmd, u8 *inbuf, u8 *outbuf) 283 + { 284 + int error; 285 + u8 buf[64]; 286 + 287 + buf[0] = cmd; 288 + error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 8); 289 + if (error) 290 + return error; 291 + 292 + ts->screen_min_x = get_unaligned_le16(outbuf); 293 + ts->screen_min_y = get_unaligned_le16(outbuf + 2); 294 + ts->screen_max_x = get_unaligned_le16(outbuf + 4); 295 + ts->screen_max_y = get_unaligned_le16(outbuf + 6); 296 + 297 + return 0; 298 + } 299 + 300 + static int api_protocol_get_tp_res(struct ilitek_ts_data *ts, 301 + u16 cmd, u8 *inbuf, u8 *outbuf) 302 + { 303 + int error; 304 + u8 buf[64]; 305 + 306 + buf[0] = cmd; 307 + error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 15); 308 + if (error) 309 + return error; 310 + 311 + ts->max_tp = outbuf[8]; 312 + if (ts->max_tp > ILITEK_SUPPORT_MAX_POINT) { 313 + dev_err(&ts->client->dev, "Invalid MAX_TP:%d from FW\n", 314 + ts->max_tp); 315 + return -EINVAL; 316 + } 317 + 318 + return 0; 319 + } 320 + 321 + static int api_protocol_get_ic_mode(struct ilitek_ts_data *ts, 322 + u16 cmd, u8 *inbuf, u8 *outbuf) 323 + { 324 + int error; 325 + u8 buf[64]; 326 + 327 + buf[0] = cmd; 328 + error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 2); 329 + if (error) 330 + return error; 331 + 332 + ts->ic_mode = outbuf[0]; 333 + return 0; 334 + } 335 + 336 + static int api_protocol_set_ic_sleep(struct ilitek_ts_data *ts, 337 + u16 cmd, u8 *inbuf, u8 *outbuf) 338 + { 339 + u8 buf[64]; 340 + 341 + buf[0] = cmd; 342 + return ilitek_i2c_write_and_read(ts, buf, 1, 0, NULL, 0); 343 + } 344 + 345 + static int api_protocol_set_ic_wake(struct ilitek_ts_data *ts, 346 + u16 cmd, u8 *inbuf, u8 *outbuf) 347 + { 348 + u8 buf[64]; 349 + 350 + buf[0] = cmd; 351 + return ilitek_i2c_write_and_read(ts, buf, 1, 0, NULL, 0); 352 + } 353 + 354 + static const struct ilitek_protocol_map ptl_func_map[] = { 355 + /* common cmds */ 356 + [GET_PTL_VER] = { 357 + ILITEK_TP_CMD_GET_PRL_VER, "GET_PTL_VER", 358 + api_protocol_get_ptl_ver 359 + }, 360 + [GET_FW_VER] = { 361 + ILITEK_TP_CMD_GET_FW_VER, "GET_FW_VER", 362 + api_protocol_get_fw_ver 363 + }, 364 + [GET_SCRN_RES] = { 365 + ILITEK_TP_CMD_GET_SCRN_RES, "GET_SCRN_RES", 366 + api_protocol_get_scrn_res 367 + }, 368 + [GET_TP_RES] = { 369 + ILITEK_TP_CMD_GET_TP_RES, "GET_TP_RES", 370 + api_protocol_get_tp_res 371 + }, 372 + [GET_IC_MODE] = { 373 + ILITEK_TP_CMD_GET_IC_MODE, "GET_IC_MODE", 374 + api_protocol_get_ic_mode 375 + }, 376 + [GET_MCU_VER] = { 377 + ILITEK_TP_CMD_GET_MCU_VER, "GET_MOD_VER", 378 + api_protocol_get_mcu_ver 379 + }, 380 + [SET_IC_SLEEP] = { 381 + ILITEK_TP_CMD_SET_IC_SLEEP, "SET_IC_SLEEP", 382 + api_protocol_set_ic_sleep 383 + }, 384 + [SET_IC_WAKE] = { 385 + ILITEK_TP_CMD_SET_IC_WAKE, "SET_IC_WAKE", 386 + api_protocol_set_ic_wake 387 + }, 388 + }; 389 + 390 + /* Probe APIs */ 391 + static void ilitek_reset(struct ilitek_ts_data *ts, int delay) 392 + { 393 + if (ts->reset_gpio) { 394 + gpiod_set_value(ts->reset_gpio, 1); 395 + mdelay(10); 396 + gpiod_set_value(ts->reset_gpio, 0); 397 + mdelay(delay); 398 + } 399 + } 400 + 401 + static int ilitek_protocol_init(struct ilitek_ts_data *ts) 402 + { 403 + int error; 404 + u8 outbuf[64]; 405 + 406 + ts->ptl_cb_func = ptl_func_map; 407 + ts->reset_time = 600; 408 + 409 + error = api_protocol_set_cmd(ts, GET_PTL_VER, NULL, outbuf); 410 + if (error) 411 + return error; 412 + 413 + /* Protocol v3 is not support currently */ 414 + if (ts->ptl.ver_major == 0x3 || 415 + ts->ptl.ver == BL_V1_6 || 416 + ts->ptl.ver == BL_V1_7) 417 + return -EINVAL; 418 + 419 + return 0; 420 + } 421 + 422 + static int ilitek_read_tp_info(struct ilitek_ts_data *ts, bool boot) 423 + { 424 + u8 outbuf[256]; 425 + int error; 426 + 427 + error = api_protocol_set_cmd(ts, GET_PTL_VER, NULL, outbuf); 428 + if (error) 429 + return error; 430 + 431 + error = api_protocol_set_cmd(ts, GET_MCU_VER, NULL, outbuf); 432 + if (error) 433 + return error; 434 + 435 + error = api_protocol_set_cmd(ts, GET_FW_VER, NULL, outbuf); 436 + if (error) 437 + return error; 438 + 439 + if (boot) { 440 + error = api_protocol_set_cmd(ts, GET_SCRN_RES, NULL, 441 + outbuf); 442 + if (error) 443 + return error; 444 + } 445 + 446 + error = api_protocol_set_cmd(ts, GET_TP_RES, NULL, outbuf); 447 + if (error) 448 + return error; 449 + 450 + error = api_protocol_set_cmd(ts, GET_IC_MODE, NULL, outbuf); 451 + if (error) 452 + return error; 453 + 454 + return 0; 455 + } 456 + 457 + static int ilitek_input_dev_init(struct device *dev, struct ilitek_ts_data *ts) 458 + { 459 + int error; 460 + struct input_dev *input; 461 + 462 + input = devm_input_allocate_device(dev); 463 + if (!input) 464 + return -ENOMEM; 465 + 466 + ts->input_dev = input; 467 + input->name = ILITEK_TS_NAME; 468 + input->id.bustype = BUS_I2C; 469 + 470 + __set_bit(INPUT_PROP_DIRECT, input->propbit); 471 + 472 + input_set_abs_params(input, ABS_MT_POSITION_X, 473 + ts->screen_min_x, ts->screen_max_x, 0, 0); 474 + input_set_abs_params(input, ABS_MT_POSITION_Y, 475 + ts->screen_min_y, ts->screen_max_y, 0, 0); 476 + 477 + touchscreen_parse_properties(input, true, &ts->prop); 478 + 479 + error = input_mt_init_slots(input, ts->max_tp, 480 + INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED); 481 + if (error) { 482 + dev_err(dev, "initialize MT slots failed, err:%d\n", error); 483 + return error; 484 + } 485 + 486 + error = input_register_device(input); 487 + if (error) { 488 + dev_err(dev, "register input device failed, err:%d\n", error); 489 + return error; 490 + } 491 + 492 + return 0; 493 + } 494 + 495 + static irqreturn_t ilitek_i2c_isr(int irq, void *dev_id) 496 + { 497 + struct ilitek_ts_data *ts = dev_id; 498 + int error; 499 + 500 + error = ilitek_process_and_report_v6(ts); 501 + if (error < 0) { 502 + dev_err(&ts->client->dev, "[%s] err:%d\n", __func__, error); 503 + return IRQ_NONE; 504 + } 505 + 506 + return IRQ_HANDLED; 507 + } 508 + 509 + static ssize_t firmware_version_show(struct device *dev, 510 + struct device_attribute *attr, char *buf) 511 + { 512 + struct i2c_client *client = to_i2c_client(dev); 513 + struct ilitek_ts_data *ts = i2c_get_clientdata(client); 514 + 515 + return scnprintf(buf, PAGE_SIZE, 516 + "fw version: [%02X%02X.%02X%02X.%02X%02X.%02X%02X]\n", 517 + ts->firmware_ver[0], ts->firmware_ver[1], 518 + ts->firmware_ver[2], ts->firmware_ver[3], 519 + ts->firmware_ver[4], ts->firmware_ver[5], 520 + ts->firmware_ver[6], ts->firmware_ver[7]); 521 + } 522 + static DEVICE_ATTR_RO(firmware_version); 523 + 524 + static ssize_t product_id_show(struct device *dev, 525 + struct device_attribute *attr, char *buf) 526 + { 527 + struct i2c_client *client = to_i2c_client(dev); 528 + struct ilitek_ts_data *ts = i2c_get_clientdata(client); 529 + 530 + return scnprintf(buf, PAGE_SIZE, "product id: [%04X], module: [%s]\n", 531 + ts->mcu_ver, ts->product_id); 532 + } 533 + static DEVICE_ATTR_RO(product_id); 534 + 535 + static struct attribute *ilitek_sysfs_attrs[] = { 536 + &dev_attr_firmware_version.attr, 537 + &dev_attr_product_id.attr, 538 + NULL 539 + }; 540 + 541 + static struct attribute_group ilitek_attrs_group = { 542 + .attrs = ilitek_sysfs_attrs, 543 + }; 544 + 545 + static int ilitek_ts_i2c_probe(struct i2c_client *client, 546 + const struct i2c_device_id *id) 547 + { 548 + struct ilitek_ts_data *ts; 549 + struct device *dev = &client->dev; 550 + int error; 551 + 552 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { 553 + dev_err(dev, "i2c check functionality failed\n"); 554 + return -ENXIO; 555 + } 556 + 557 + ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL); 558 + if (!ts) 559 + return -ENOMEM; 560 + 561 + ts->client = client; 562 + i2c_set_clientdata(client, ts); 563 + 564 + ts->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); 565 + if (IS_ERR(ts->reset_gpio)) { 566 + error = PTR_ERR(ts->reset_gpio); 567 + dev_err(dev, "request gpiod failed: %d", error); 568 + return error; 569 + } 570 + 571 + ilitek_reset(ts, 1000); 572 + 573 + error = ilitek_protocol_init(ts); 574 + if (error) { 575 + dev_err(dev, "protocol init failed: %d", error); 576 + return error; 577 + } 578 + 579 + error = ilitek_read_tp_info(ts, true); 580 + if (error) { 581 + dev_err(dev, "read tp info failed: %d", error); 582 + return error; 583 + } 584 + 585 + error = ilitek_input_dev_init(dev, ts); 586 + if (error) { 587 + dev_err(dev, "input dev init failed: %d", error); 588 + return error; 589 + } 590 + 591 + error = devm_request_threaded_irq(dev, ts->client->irq, 592 + NULL, ilitek_i2c_isr, IRQF_ONESHOT, 593 + "ilitek_touch_irq", ts); 594 + if (error) { 595 + dev_err(dev, "request threaded irq failed: %d\n", error); 596 + return error; 597 + } 598 + 599 + error = devm_device_add_group(dev, &ilitek_attrs_group); 600 + if (error) { 601 + dev_err(dev, "sysfs create group failed: %d\n", error); 602 + return error; 603 + } 604 + 605 + return 0; 606 + } 607 + 608 + static int __maybe_unused ilitek_suspend(struct device *dev) 609 + { 610 + struct i2c_client *client = to_i2c_client(dev); 611 + struct ilitek_ts_data *ts = i2c_get_clientdata(client); 612 + int error; 613 + 614 + disable_irq(client->irq); 615 + 616 + if (!device_may_wakeup(dev)) { 617 + error = api_protocol_set_cmd(ts, SET_IC_SLEEP, NULL, NULL); 618 + if (error) 619 + return error; 620 + } 621 + 622 + return 0; 623 + } 624 + 625 + static int __maybe_unused ilitek_resume(struct device *dev) 626 + { 627 + struct i2c_client *client = to_i2c_client(dev); 628 + struct ilitek_ts_data *ts = i2c_get_clientdata(client); 629 + int error; 630 + 631 + if (!device_may_wakeup(dev)) { 632 + error = api_protocol_set_cmd(ts, SET_IC_WAKE, NULL, NULL); 633 + if (error) 634 + return error; 635 + 636 + ilitek_reset(ts, ts->reset_time); 637 + } 638 + 639 + enable_irq(client->irq); 640 + 641 + return 0; 642 + } 643 + 644 + static SIMPLE_DEV_PM_OPS(ilitek_pm_ops, ilitek_suspend, ilitek_resume); 645 + 646 + static const struct i2c_device_id ilitek_ts_i2c_id[] = { 647 + { ILITEK_TS_NAME, 0 }, 648 + { }, 649 + }; 650 + MODULE_DEVICE_TABLE(i2c, ilitek_ts_i2c_id); 651 + 652 + #ifdef CONFIG_ACPI 653 + static const struct acpi_device_id ilitekts_acpi_id[] = { 654 + { "ILTK0001", 0 }, 655 + { }, 656 + }; 657 + MODULE_DEVICE_TABLE(acpi, ilitekts_acpi_id); 658 + #endif 659 + 660 + #ifdef CONFIG_OF 661 + static const struct of_device_id ilitek_ts_i2c_match[] = { 662 + {.compatible = "ilitek,ili2130",}, 663 + {.compatible = "ilitek,ili2131",}, 664 + {.compatible = "ilitek,ili2132",}, 665 + {.compatible = "ilitek,ili2316",}, 666 + {.compatible = "ilitek,ili2322",}, 667 + {.compatible = "ilitek,ili2323",}, 668 + {.compatible = "ilitek,ili2326",}, 669 + {.compatible = "ilitek,ili2520",}, 670 + {.compatible = "ilitek,ili2521",}, 671 + { }, 672 + }; 673 + MODULE_DEVICE_TABLE(of, ilitek_ts_i2c_match); 674 + #endif 675 + 676 + static struct i2c_driver ilitek_ts_i2c_driver = { 677 + .driver = { 678 + .name = ILITEK_TS_NAME, 679 + .pm = &ilitek_pm_ops, 680 + .of_match_table = of_match_ptr(ilitek_ts_i2c_match), 681 + .acpi_match_table = ACPI_PTR(ilitekts_acpi_id), 682 + }, 683 + .probe = ilitek_ts_i2c_probe, 684 + .id_table = ilitek_ts_i2c_id, 685 + }; 686 + module_i2c_driver(ilitek_ts_i2c_driver); 687 + 688 + MODULE_AUTHOR("ILITEK"); 689 + MODULE_DESCRIPTION("ILITEK I2C Touchscreen Driver"); 690 + MODULE_LICENSE("GPL");
+84 -87
drivers/input/touchscreen/iqs5xx.c
··· 8 8 * made available by the vendor. Firmware files may be pushed to the device's 9 9 * nonvolatile memory by writing the filename to the 'fw_file' sysfs control. 10 10 * 11 - * Link to PC-based configuration tool and data sheet: http://www.azoteq.com/ 11 + * Link to PC-based configuration tool and datasheet: https://www.azoteq.com/ 12 12 */ 13 13 14 14 #include <linux/bits.h> ··· 32 32 #define IQS5XX_NUM_RETRIES 10 33 33 #define IQS5XX_NUM_CONTACTS 5 34 34 #define IQS5XX_WR_BYTES_MAX 2 35 - #define IQS5XX_XY_RES_MAX 0xFFFE 36 35 37 36 #define IQS5XX_PROD_NUM_IQS550 40 38 37 #define IQS5XX_PROD_NUM_IQS572 58 39 38 #define IQS5XX_PROD_NUM_IQS525 52 40 - #define IQS5XX_PROJ_NUM_A000 0 41 - #define IQS5XX_PROJ_NUM_B000 15 42 - #define IQS5XX_MAJOR_VER_MIN 2 43 39 44 40 #define IQS5XX_SHOW_RESET BIT(7) 45 41 #define IQS5XX_ACK_RESET BIT(7) ··· 60 64 #define IQS5XX_SYS_CFG1 0x058F 61 65 #define IQS5XX_X_RES 0x066E 62 66 #define IQS5XX_Y_RES 0x0670 67 + #define IQS5XX_EXP_FILE 0x0677 63 68 #define IQS5XX_CHKSM 0x83C0 64 69 #define IQS5XX_APP 0x8400 65 70 #define IQS5XX_CSTM 0xBE00 ··· 84 87 #define IQS5XX_BL_CMD_CRC 0x03 85 88 #define IQS5XX_BL_BLK_LEN_MAX 64 86 89 #define IQS5XX_BL_ID 0x0200 87 - #define IQS5XX_BL_STATUS_RESET 0x00 88 - #define IQS5XX_BL_STATUS_AVAIL 0xA5 89 90 #define IQS5XX_BL_STATUS_NONE 0xEE 90 91 #define IQS5XX_BL_CRC_PASS 0x00 91 92 #define IQS5XX_BL_CRC_FAIL 0x01 92 93 #define IQS5XX_BL_ATTEMPTS 3 93 - 94 - struct iqs5xx_private { 95 - struct i2c_client *client; 96 - struct input_dev *input; 97 - struct gpio_desc *reset_gpio; 98 - struct touchscreen_properties prop; 99 - struct mutex lock; 100 - u8 bl_status; 101 - }; 102 94 103 95 struct iqs5xx_dev_id_info { 104 96 __be16 prod_num; ··· 119 133 __be16 rel_y; 120 134 struct iqs5xx_touch_data touch_data[IQS5XX_NUM_CONTACTS]; 121 135 } __packed; 136 + 137 + struct iqs5xx_private { 138 + struct i2c_client *client; 139 + struct input_dev *input; 140 + struct gpio_desc *reset_gpio; 141 + struct touchscreen_properties prop; 142 + struct mutex lock; 143 + struct iqs5xx_dev_id_info dev_id_info; 144 + u8 exp_file[2]; 145 + }; 122 146 123 147 static int iqs5xx_read_burst(struct i2c_client *client, 124 148 u16 reg, void *val, u16 len) ··· 442 446 struct iqs5xx_private *iqs5xx = i2c_get_clientdata(client); 443 447 int error1, error2; 444 448 445 - if (iqs5xx->bl_status == IQS5XX_BL_STATUS_RESET) 449 + if (!iqs5xx->dev_id_info.bl_status) 446 450 return 0; 447 451 448 452 mutex_lock(&iqs5xx->lock); ··· 500 504 input->open = iqs5xx_open; 501 505 input->close = iqs5xx_close; 502 506 503 - input_set_capability(input, EV_ABS, ABS_MT_POSITION_X); 504 - input_set_capability(input, EV_ABS, ABS_MT_POSITION_Y); 505 - input_set_capability(input, EV_ABS, ABS_MT_PRESSURE); 506 - 507 507 input_set_drvdata(input, iqs5xx); 508 508 iqs5xx->input = input; 509 509 } ··· 512 520 if (error) 513 521 return error; 514 522 515 - input_abs_set_max(iqs5xx->input, ABS_MT_POSITION_X, max_x); 516 - input_abs_set_max(iqs5xx->input, ABS_MT_POSITION_Y, max_y); 523 + input_set_abs_params(iqs5xx->input, ABS_MT_POSITION_X, 0, max_x, 0, 0); 524 + input_set_abs_params(iqs5xx->input, ABS_MT_POSITION_Y, 0, max_y, 0, 0); 525 + input_set_abs_params(iqs5xx->input, ABS_MT_PRESSURE, 0, U16_MAX, 0, 0); 517 526 518 527 touchscreen_parse_properties(iqs5xx->input, true, prop); 519 528 520 - if (prop->max_x > IQS5XX_XY_RES_MAX) { 521 - dev_err(&client->dev, "Invalid maximum x-coordinate: %u > %u\n", 522 - prop->max_x, IQS5XX_XY_RES_MAX); 529 + /* 530 + * The device reserves 0xFFFF for coordinates that correspond to slots 531 + * which are not in a state of touch. 532 + */ 533 + if (prop->max_x >= U16_MAX || prop->max_y >= U16_MAX) { 534 + dev_err(&client->dev, "Invalid touchscreen size: %u*%u\n", 535 + prop->max_x, prop->max_y); 523 536 return -EINVAL; 524 - } else if (prop->max_x != max_x) { 537 + } 538 + 539 + if (prop->max_x != max_x) { 525 540 error = iqs5xx_write_word(client, IQS5XX_X_RES, prop->max_x); 526 541 if (error) 527 542 return error; 528 543 } 529 544 530 - if (prop->max_y > IQS5XX_XY_RES_MAX) { 531 - dev_err(&client->dev, "Invalid maximum y-coordinate: %u > %u\n", 532 - prop->max_y, IQS5XX_XY_RES_MAX); 533 - return -EINVAL; 534 - } else if (prop->max_y != max_y) { 545 + if (prop->max_y != max_y) { 535 546 error = iqs5xx_write_word(client, IQS5XX_Y_RES, prop->max_y); 536 547 if (error) 537 548 return error; ··· 569 574 * the missing zero is prepended). 570 575 */ 571 576 buf[0] = 0; 572 - dev_id_info = (struct iqs5xx_dev_id_info *)&buf[(buf[1] > 0) ? 0 : 1]; 577 + dev_id_info = (struct iqs5xx_dev_id_info *)&buf[buf[1] ? 0 : 1]; 573 578 574 579 switch (be16_to_cpu(dev_id_info->prod_num)) { 575 580 case IQS5XX_PROD_NUM_IQS550: ··· 582 587 return -EINVAL; 583 588 } 584 589 585 - switch (be16_to_cpu(dev_id_info->proj_num)) { 586 - case IQS5XX_PROJ_NUM_A000: 587 - dev_err(&client->dev, "Unsupported project number: %u\n", 588 - be16_to_cpu(dev_id_info->proj_num)); 589 - return iqs5xx_bl_open(client); 590 - case IQS5XX_PROJ_NUM_B000: 591 - break; 592 - default: 593 - dev_err(&client->dev, "Unrecognized project number: %u\n", 594 - be16_to_cpu(dev_id_info->proj_num)); 595 - return -EINVAL; 596 - } 597 - 598 - if (dev_id_info->major_ver < IQS5XX_MAJOR_VER_MIN) { 599 - dev_err(&client->dev, "Unsupported major version: %u\n", 600 - dev_id_info->major_ver); 590 + /* 591 + * With the product number recognized yet shifted by one byte, open the 592 + * bootloader and wait for user space to convert the A000 device into a 593 + * B000 device via new firmware. 594 + */ 595 + if (buf[1]) { 596 + dev_err(&client->dev, "Opening bootloader for A000 device\n"); 601 597 return iqs5xx_bl_open(client); 602 598 } 603 599 604 - switch (dev_id_info->bl_status) { 605 - case IQS5XX_BL_STATUS_AVAIL: 606 - case IQS5XX_BL_STATUS_NONE: 607 - break; 608 - default: 609 - dev_err(&client->dev, 610 - "Unrecognized bootloader status: 0x%02X\n", 611 - dev_id_info->bl_status); 612 - return -EINVAL; 613 - } 600 + error = iqs5xx_read_burst(client, IQS5XX_EXP_FILE, 601 + iqs5xx->exp_file, sizeof(iqs5xx->exp_file)); 602 + if (error) 603 + return error; 614 604 615 605 error = iqs5xx_axis_init(client); 616 606 if (error) ··· 620 640 if (error) 621 641 return error; 622 642 623 - iqs5xx->bl_status = dev_id_info->bl_status; 643 + iqs5xx->dev_id_info = *dev_id_info; 624 644 625 645 /* 626 646 * The following delay allows ATI to complete before the open and close ··· 646 666 * RDY output during bootloader mode. If the device operates outside of 647 667 * bootloader mode, the input device is guaranteed to be allocated. 648 668 */ 649 - if (iqs5xx->bl_status == IQS5XX_BL_STATUS_RESET) 669 + if (!iqs5xx->dev_id_info.bl_status) 650 670 return IRQ_NONE; 651 671 652 672 error = iqs5xx_read_burst(client, IQS5XX_SYS_INFO0, ··· 832 852 static int iqs5xx_fw_file_write(struct i2c_client *client, const char *fw_file) 833 853 { 834 854 struct iqs5xx_private *iqs5xx = i2c_get_clientdata(client); 835 - int error, error_bl = 0; 855 + int error, error_init = 0; 836 856 u8 *pmap; 837 - 838 - if (iqs5xx->bl_status == IQS5XX_BL_STATUS_NONE) 839 - return -EPERM; 840 857 841 858 pmap = kzalloc(IQS5XX_PMAP_LEN, GFP_KERNEL); 842 859 if (!pmap) ··· 852 875 */ 853 876 disable_irq(client->irq); 854 877 855 - iqs5xx->bl_status = IQS5XX_BL_STATUS_RESET; 878 + iqs5xx->dev_id_info.bl_status = 0; 856 879 857 880 error = iqs5xx_bl_cmd(client, IQS5XX_BL_CMD_VER, 0); 858 881 if (error) { ··· 872 895 error = iqs5xx_bl_verify(client, IQS5XX_CSTM, 873 896 pmap + IQS5XX_CHKSM_LEN + IQS5XX_APP_LEN, 874 897 IQS5XX_CSTM_LEN); 875 - if (error) 876 - goto err_reset; 877 - 878 - error = iqs5xx_bl_cmd(client, IQS5XX_BL_CMD_EXEC, 0); 879 898 880 899 err_reset: 881 - if (error) { 882 - iqs5xx_reset(client); 883 - usleep_range(10000, 10100); 884 - } 900 + iqs5xx_reset(client); 901 + usleep_range(15000, 15100); 885 902 886 - error_bl = error; 887 - error = iqs5xx_dev_init(client); 888 - if (!error && iqs5xx->bl_status == IQS5XX_BL_STATUS_RESET) 889 - error = -EINVAL; 903 + error_init = iqs5xx_dev_init(client); 904 + if (!iqs5xx->dev_id_info.bl_status) 905 + error_init = error_init ? : -EINVAL; 890 906 891 907 enable_irq(client->irq); 892 908 ··· 888 918 err_kfree: 889 919 kfree(pmap); 890 920 891 - if (error_bl) 892 - return error_bl; 893 - 894 - return error; 921 + return error ? : error_init; 895 922 } 896 923 897 924 static ssize_t fw_file_store(struct device *dev, ··· 935 968 return count; 936 969 } 937 970 971 + static ssize_t fw_info_show(struct device *dev, 972 + struct device_attribute *attr, char *buf) 973 + { 974 + struct iqs5xx_private *iqs5xx = dev_get_drvdata(dev); 975 + 976 + if (!iqs5xx->dev_id_info.bl_status) 977 + return -ENODATA; 978 + 979 + return scnprintf(buf, PAGE_SIZE, "%u.%u.%u.%u:%u.%u\n", 980 + be16_to_cpu(iqs5xx->dev_id_info.prod_num), 981 + be16_to_cpu(iqs5xx->dev_id_info.proj_num), 982 + iqs5xx->dev_id_info.major_ver, 983 + iqs5xx->dev_id_info.minor_ver, 984 + iqs5xx->exp_file[0], iqs5xx->exp_file[1]); 985 + } 986 + 938 987 static DEVICE_ATTR_WO(fw_file); 988 + static DEVICE_ATTR_RO(fw_info); 939 989 940 990 static struct attribute *iqs5xx_attrs[] = { 941 991 &dev_attr_fw_file.attr, 992 + &dev_attr_fw_info.attr, 942 993 NULL, 943 994 }; 944 995 996 + static umode_t iqs5xx_attr_is_visible(struct kobject *kobj, 997 + struct attribute *attr, int i) 998 + { 999 + struct device *dev = kobj_to_dev(kobj); 1000 + struct iqs5xx_private *iqs5xx = dev_get_drvdata(dev); 1001 + 1002 + if (attr == &dev_attr_fw_file.attr && 1003 + (iqs5xx->dev_id_info.bl_status == IQS5XX_BL_STATUS_NONE || 1004 + !iqs5xx->reset_gpio)) 1005 + return 0; 1006 + 1007 + return attr->mode; 1008 + } 1009 + 945 1010 static const struct attribute_group iqs5xx_attr_group = { 1011 + .is_visible = iqs5xx_attr_is_visible, 946 1012 .attrs = iqs5xx_attrs, 947 1013 }; 948 1014 ··· 1032 1032 i2c_set_clientdata(client, iqs5xx); 1033 1033 iqs5xx->client = client; 1034 1034 1035 - iqs5xx->reset_gpio = devm_gpiod_get(&client->dev, 1036 - "reset", GPIOD_OUT_LOW); 1035 + iqs5xx->reset_gpio = devm_gpiod_get_optional(&client->dev, 1036 + "reset", GPIOD_OUT_LOW); 1037 1037 if (IS_ERR(iqs5xx->reset_gpio)) { 1038 1038 error = PTR_ERR(iqs5xx->reset_gpio); 1039 1039 dev_err(&client->dev, "Failed to request GPIO: %d\n", error); ··· 1041 1041 } 1042 1042 1043 1043 mutex_init(&iqs5xx->lock); 1044 - 1045 - iqs5xx_reset(client); 1046 - usleep_range(10000, 10100); 1047 1044 1048 1045 error = iqs5xx_dev_init(client); 1049 1046 if (error)
+5 -5
drivers/input/touchscreen/lpc32xx_ts.c
··· 34 34 #define LPC32XX_TSC_AUX_MIN 0x38 35 35 #define LPC32XX_TSC_AUX_MAX 0x3C 36 36 37 - #define LPC32XX_TSC_STAT_FIFO_OVRRN (1 << 8) 38 - #define LPC32XX_TSC_STAT_FIFO_EMPTY (1 << 7) 37 + #define LPC32XX_TSC_STAT_FIFO_OVRRN BIT(8) 38 + #define LPC32XX_TSC_STAT_FIFO_EMPTY BIT(7) 39 39 40 40 #define LPC32XX_TSC_SEL_DEFVAL 0x0284 41 41 42 42 #define LPC32XX_TSC_ADCCON_IRQ_TO_FIFO_4 (0x1 << 11) 43 43 #define LPC32XX_TSC_ADCCON_X_SAMPLE_SIZE(s) ((10 - (s)) << 7) 44 44 #define LPC32XX_TSC_ADCCON_Y_SAMPLE_SIZE(s) ((10 - (s)) << 4) 45 - #define LPC32XX_TSC_ADCCON_POWER_UP (1 << 2) 46 - #define LPC32XX_TSC_ADCCON_AUTO_EN (1 << 0) 45 + #define LPC32XX_TSC_ADCCON_POWER_UP BIT(2) 46 + #define LPC32XX_TSC_ADCCON_AUTO_EN BIT(0) 47 47 48 - #define LPC32XX_TSC_FIFO_TS_P_LEVEL (1 << 31) 48 + #define LPC32XX_TSC_FIFO_TS_P_LEVEL BIT(31) 49 49 #define LPC32XX_TSC_FIFO_NORMALIZE_X_VAL(x) (((x) & 0x03FF0000) >> 16) 50 50 #define LPC32XX_TSC_FIFO_NORMALIZE_Y_VAL(y) ((y) & 0x000003FF) 51 51
+2 -3
drivers/input/touchscreen/melfas_mip4.c
··· 1502 1502 1503 1503 error = devm_request_threaded_irq(&client->dev, client->irq, 1504 1504 NULL, mip4_interrupt, 1505 - IRQF_ONESHOT, MIP4_DEVICE_NAME, ts); 1505 + IRQF_ONESHOT | IRQF_NO_AUTOEN, 1506 + MIP4_DEVICE_NAME, ts); 1506 1507 if (error) { 1507 1508 dev_err(&client->dev, 1508 1509 "Failed to request interrupt %d: %d\n", 1509 1510 client->irq, error); 1510 1511 return error; 1511 1512 } 1512 - 1513 - disable_irq(client->irq); 1514 1513 1515 1514 error = input_register_device(input); 1516 1515 if (error) {
+18 -8
drivers/input/touchscreen/mms114.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 - // Melfas MMS114/MMS152 touchscreen device driver 2 + // Melfas MMS114/MMS136/MMS152 touchscreen device driver 3 3 // 4 4 // Copyright (c) 2012 Samsung Electronics Co., Ltd. 5 5 // Author: Joonyoung Shim <jy0922.shim@samsung.com> ··· 44 44 #define MMS114_MAX_AREA 0xff 45 45 46 46 #define MMS114_MAX_TOUCH 10 47 - #define MMS114_PACKET_NUM 8 47 + #define MMS114_EVENT_SIZE 8 48 + #define MMS136_EVENT_SIZE 6 48 49 49 50 /* Touch type */ 50 51 #define MMS114_TYPE_NONE 0 ··· 54 53 55 54 enum mms_type { 56 55 TYPE_MMS114 = 114, 56 + TYPE_MMS136 = 136, 57 57 TYPE_MMS152 = 152, 58 58 TYPE_MMS345L = 345, 59 59 }; ··· 211 209 if (packet_size <= 0) 212 210 goto out; 213 211 214 - touch_size = packet_size / MMS114_PACKET_NUM; 212 + /* MMS136 has slightly different event size */ 213 + if (data->type == TYPE_MMS136) 214 + touch_size = packet_size / MMS136_EVENT_SIZE; 215 + else 216 + touch_size = packet_size / MMS114_EVENT_SIZE; 215 217 216 218 error = __mms114_read_reg(data, MMS114_INFORMATION, packet_size, 217 219 (u8 *)touch); ··· 281 275 break; 282 276 283 277 case TYPE_MMS114: 278 + case TYPE_MMS136: 284 279 error = __mms114_read_reg(data, MMS114_TSP_REV, 6, buf); 285 280 if (error) 286 281 return error; ··· 304 297 if (error < 0) 305 298 return error; 306 299 307 - /* Only MMS114 has configuration and power on registers */ 308 - if (data->type != TYPE_MMS114) 300 + /* Only MMS114 and MMS136 have configuration and power on registers */ 301 + if (data->type != TYPE_MMS114 && data->type != TYPE_MMS136) 309 302 return 0; 310 303 311 304 error = mms114_set_active(data, true); ··· 487 480 0, data->props.max_y, 0, 0); 488 481 } 489 482 490 - if (data->type == TYPE_MMS114) { 483 + if (data->type == TYPE_MMS114 || data->type == TYPE_MMS136) { 491 484 /* 492 485 * The firmware handles movement and pressure fuzz, so 493 486 * don't duplicate that in software. ··· 537 530 } 538 531 539 532 error = devm_request_threaded_irq(&client->dev, client->irq, 540 - NULL, mms114_interrupt, IRQF_ONESHOT, 533 + NULL, mms114_interrupt, 534 + IRQF_ONESHOT | IRQF_NO_AUTOEN, 541 535 dev_name(&client->dev), data); 542 536 if (error) { 543 537 dev_err(&client->dev, "Failed to register interrupt\n"); 544 538 return error; 545 539 } 546 - disable_irq(client->irq); 547 540 548 541 error = input_register_device(data->input_dev); 549 542 if (error) { ··· 611 604 { 612 605 .compatible = "melfas,mms114", 613 606 .data = (void *)TYPE_MMS114, 607 + }, { 608 + .compatible = "melfas,mms136", 609 + .data = (void *)TYPE_MMS136, 614 610 }, { 615 611 .compatible = "melfas,mms152", 616 612 .data = (void *)TYPE_MMS152,
+337
drivers/input/touchscreen/msg2638.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Driver for MStar msg2638 touchscreens 4 + * 5 + * Copyright (c) 2021 Vincent Knecht <vincent.knecht@mailoo.org> 6 + * 7 + * Checksum and IRQ handler based on mstar_drv_common.c and 8 + * mstar_drv_mutual_fw_control.c 9 + * Copyright (c) 2006-2012 MStar Semiconductor, Inc. 10 + * 11 + * Driver structure based on zinitix.c by Michael Srba <Michael.Srba@seznam.cz> 12 + */ 13 + 14 + #include <linux/delay.h> 15 + #include <linux/gpio/consumer.h> 16 + #include <linux/i2c.h> 17 + #include <linux/input.h> 18 + #include <linux/input/mt.h> 19 + #include <linux/input/touchscreen.h> 20 + #include <linux/interrupt.h> 21 + #include <linux/kernel.h> 22 + #include <linux/mod_devicetable.h> 23 + #include <linux/module.h> 24 + #include <linux/regulator/consumer.h> 25 + #include <linux/slab.h> 26 + 27 + #define MODE_DATA_RAW 0x5A 28 + 29 + #define MAX_SUPPORTED_FINGER_NUM 5 30 + 31 + #define CHIP_ON_DELAY_MS 15 32 + #define FIRMWARE_ON_DELAY_MS 50 33 + #define RESET_DELAY_MIN_US 10000 34 + #define RESET_DELAY_MAX_US 11000 35 + 36 + struct packet { 37 + u8 xy_hi; /* higher bits of x and y coordinates */ 38 + u8 x_low; 39 + u8 y_low; 40 + u8 pressure; 41 + }; 42 + 43 + struct touch_event { 44 + u8 mode; 45 + struct packet pkt[MAX_SUPPORTED_FINGER_NUM]; 46 + u8 proximity; 47 + u8 checksum; 48 + }; 49 + 50 + struct msg2638_ts_data { 51 + struct i2c_client *client; 52 + struct input_dev *input_dev; 53 + struct touchscreen_properties prop; 54 + struct regulator_bulk_data supplies[2]; 55 + struct gpio_desc *reset_gpiod; 56 + }; 57 + 58 + static u8 msg2638_checksum(u8 *data, u32 length) 59 + { 60 + s32 sum = 0; 61 + u32 i; 62 + 63 + for (i = 0; i < length; i++) 64 + sum += data[i]; 65 + 66 + return (u8)((-sum) & 0xFF); 67 + } 68 + 69 + static irqreturn_t msg2638_ts_irq_handler(int irq, void *msg2638_handler) 70 + { 71 + struct msg2638_ts_data *msg2638 = msg2638_handler; 72 + struct i2c_client *client = msg2638->client; 73 + struct input_dev *input = msg2638->input_dev; 74 + struct touch_event touch_event; 75 + u32 len = sizeof(touch_event); 76 + struct i2c_msg msg[] = { 77 + { 78 + .addr = client->addr, 79 + .flags = I2C_M_RD, 80 + .len = sizeof(touch_event), 81 + .buf = (u8 *)&touch_event, 82 + }, 83 + }; 84 + struct packet *p; 85 + u16 x, y; 86 + int ret; 87 + int i; 88 + 89 + ret = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg)); 90 + if (ret != ARRAY_SIZE(msg)) { 91 + dev_err(&client->dev, 92 + "Failed I2C transfer in irq handler: %d\n", 93 + ret < 0 ? ret : -EIO); 94 + goto out; 95 + } 96 + 97 + if (touch_event.mode != MODE_DATA_RAW) 98 + goto out; 99 + 100 + if (msg2638_checksum((u8 *)&touch_event, len - 1) != 101 + touch_event.checksum) { 102 + dev_err(&client->dev, "Failed checksum!\n"); 103 + goto out; 104 + } 105 + 106 + for (i = 0; i < MAX_SUPPORTED_FINGER_NUM; i++) { 107 + p = &touch_event.pkt[i]; 108 + 109 + /* Ignore non-pressed finger data */ 110 + if (p->xy_hi == 0xFF && p->x_low == 0xFF && p->y_low == 0xFF) 111 + continue; 112 + 113 + x = (((p->xy_hi & 0xF0) << 4) | p->x_low); 114 + y = (((p->xy_hi & 0x0F) << 8) | p->y_low); 115 + 116 + input_mt_slot(input, i); 117 + input_mt_report_slot_state(input, MT_TOOL_FINGER, true); 118 + touchscreen_report_pos(input, &msg2638->prop, x, y, true); 119 + } 120 + 121 + input_mt_sync_frame(msg2638->input_dev); 122 + input_sync(msg2638->input_dev); 123 + 124 + out: 125 + return IRQ_HANDLED; 126 + } 127 + 128 + static void msg2638_reset(struct msg2638_ts_data *msg2638) 129 + { 130 + gpiod_set_value_cansleep(msg2638->reset_gpiod, 1); 131 + usleep_range(RESET_DELAY_MIN_US, RESET_DELAY_MAX_US); 132 + gpiod_set_value_cansleep(msg2638->reset_gpiod, 0); 133 + msleep(FIRMWARE_ON_DELAY_MS); 134 + } 135 + 136 + static int msg2638_start(struct msg2638_ts_data *msg2638) 137 + { 138 + int error; 139 + 140 + error = regulator_bulk_enable(ARRAY_SIZE(msg2638->supplies), 141 + msg2638->supplies); 142 + if (error) { 143 + dev_err(&msg2638->client->dev, 144 + "Failed to enable regulators: %d\n", error); 145 + return error; 146 + } 147 + 148 + msleep(CHIP_ON_DELAY_MS); 149 + 150 + msg2638_reset(msg2638); 151 + 152 + enable_irq(msg2638->client->irq); 153 + 154 + return 0; 155 + } 156 + 157 + static int msg2638_stop(struct msg2638_ts_data *msg2638) 158 + { 159 + int error; 160 + 161 + disable_irq(msg2638->client->irq); 162 + 163 + error = regulator_bulk_disable(ARRAY_SIZE(msg2638->supplies), 164 + msg2638->supplies); 165 + if (error) { 166 + dev_err(&msg2638->client->dev, 167 + "Failed to disable regulators: %d\n", error); 168 + return error; 169 + } 170 + 171 + return 0; 172 + } 173 + 174 + static int msg2638_input_open(struct input_dev *dev) 175 + { 176 + struct msg2638_ts_data *msg2638 = input_get_drvdata(dev); 177 + 178 + return msg2638_start(msg2638); 179 + } 180 + 181 + static void msg2638_input_close(struct input_dev *dev) 182 + { 183 + struct msg2638_ts_data *msg2638 = input_get_drvdata(dev); 184 + 185 + msg2638_stop(msg2638); 186 + } 187 + 188 + static int msg2638_init_input_dev(struct msg2638_ts_data *msg2638) 189 + { 190 + struct device *dev = &msg2638->client->dev; 191 + struct input_dev *input_dev; 192 + int error; 193 + 194 + input_dev = devm_input_allocate_device(dev); 195 + if (!input_dev) { 196 + dev_err(dev, "Failed to allocate input device.\n"); 197 + return -ENOMEM; 198 + } 199 + 200 + input_set_drvdata(input_dev, msg2638); 201 + msg2638->input_dev = input_dev; 202 + 203 + input_dev->name = "MStar TouchScreen"; 204 + input_dev->phys = "input/ts"; 205 + input_dev->id.bustype = BUS_I2C; 206 + input_dev->open = msg2638_input_open; 207 + input_dev->close = msg2638_input_close; 208 + 209 + input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_X); 210 + input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_Y); 211 + 212 + touchscreen_parse_properties(input_dev, true, &msg2638->prop); 213 + if (!msg2638->prop.max_x || !msg2638->prop.max_y) { 214 + dev_err(dev, "touchscreen-size-x and/or touchscreen-size-y not set in properties\n"); 215 + return -EINVAL; 216 + } 217 + 218 + error = input_mt_init_slots(input_dev, MAX_SUPPORTED_FINGER_NUM, 219 + INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED); 220 + if (error) { 221 + dev_err(dev, "Failed to initialize MT slots: %d\n", error); 222 + return error; 223 + } 224 + 225 + error = input_register_device(input_dev); 226 + if (error) { 227 + dev_err(dev, "Failed to register input device: %d\n", error); 228 + return error; 229 + } 230 + 231 + return 0; 232 + } 233 + 234 + static int msg2638_ts_probe(struct i2c_client *client) 235 + { 236 + struct device *dev = &client->dev; 237 + struct msg2638_ts_data *msg2638; 238 + int error; 239 + 240 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { 241 + dev_err(dev, "Failed to assert adapter's support for plain I2C.\n"); 242 + return -ENXIO; 243 + } 244 + 245 + msg2638 = devm_kzalloc(dev, sizeof(*msg2638), GFP_KERNEL); 246 + if (!msg2638) 247 + return -ENOMEM; 248 + 249 + msg2638->client = client; 250 + i2c_set_clientdata(client, msg2638); 251 + 252 + msg2638->supplies[0].supply = "vdd"; 253 + msg2638->supplies[1].supply = "vddio"; 254 + error = devm_regulator_bulk_get(dev, ARRAY_SIZE(msg2638->supplies), 255 + msg2638->supplies); 256 + if (error) { 257 + dev_err(dev, "Failed to get regulators: %d\n", error); 258 + return error; 259 + } 260 + 261 + msg2638->reset_gpiod = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); 262 + if (IS_ERR(msg2638->reset_gpiod)) { 263 + error = PTR_ERR(msg2638->reset_gpiod); 264 + dev_err(dev, "Failed to request reset GPIO: %d\n", error); 265 + return error; 266 + } 267 + 268 + error = msg2638_init_input_dev(msg2638); 269 + if (error) { 270 + dev_err(dev, "Failed to initialize input device: %d\n", error); 271 + return error; 272 + } 273 + 274 + error = devm_request_threaded_irq(dev, client->irq, 275 + NULL, msg2638_ts_irq_handler, 276 + IRQF_ONESHOT | IRQF_NO_AUTOEN, 277 + client->name, msg2638); 278 + if (error) { 279 + dev_err(dev, "Failed to request IRQ: %d\n", error); 280 + return error; 281 + } 282 + 283 + return 0; 284 + } 285 + 286 + static int __maybe_unused msg2638_suspend(struct device *dev) 287 + { 288 + struct i2c_client *client = to_i2c_client(dev); 289 + struct msg2638_ts_data *msg2638 = i2c_get_clientdata(client); 290 + 291 + mutex_lock(&msg2638->input_dev->mutex); 292 + 293 + if (input_device_enabled(msg2638->input_dev)) 294 + msg2638_stop(msg2638); 295 + 296 + mutex_unlock(&msg2638->input_dev->mutex); 297 + 298 + return 0; 299 + } 300 + 301 + static int __maybe_unused msg2638_resume(struct device *dev) 302 + { 303 + struct i2c_client *client = to_i2c_client(dev); 304 + struct msg2638_ts_data *msg2638 = i2c_get_clientdata(client); 305 + int ret = 0; 306 + 307 + mutex_lock(&msg2638->input_dev->mutex); 308 + 309 + if (input_device_enabled(msg2638->input_dev)) 310 + ret = msg2638_start(msg2638); 311 + 312 + mutex_unlock(&msg2638->input_dev->mutex); 313 + 314 + return ret; 315 + } 316 + 317 + static SIMPLE_DEV_PM_OPS(msg2638_pm_ops, msg2638_suspend, msg2638_resume); 318 + 319 + static const struct of_device_id msg2638_of_match[] = { 320 + { .compatible = "mstar,msg2638" }, 321 + { } 322 + }; 323 + MODULE_DEVICE_TABLE(of, msg2638_of_match); 324 + 325 + static struct i2c_driver msg2638_ts_driver = { 326 + .probe_new = msg2638_ts_probe, 327 + .driver = { 328 + .name = "MStar-TS", 329 + .pm = &msg2638_pm_ops, 330 + .of_match_table = msg2638_of_match, 331 + }, 332 + }; 333 + module_i2c_driver(msg2638_ts_driver); 334 + 335 + MODULE_AUTHOR("Vincent Knecht <vincent.knecht@mailoo.org>"); 336 + MODULE_DESCRIPTION("MStar MSG2638 touchscreen driver"); 337 + MODULE_LICENSE("GPL v2");
+7 -6
drivers/input/touchscreen/of_touchscreen.c drivers/input/touchscreen.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 2 /* 3 - * Generic DT helper functions for touchscreen devices 3 + * Generic helper functions for touchscreens and other two-dimensional 4 + * pointing devices 4 5 * 5 6 * Copyright (c) 2014 Sebastian Reichel <sre@kernel.org> 6 7 */ ··· 38 37 39 38 if (!test_bit(axis, dev->absbit)) { 40 39 dev_warn(&dev->dev, 41 - "DT specifies parameters but the axis %lu is not set up\n", 40 + "Parameters are specified but the axis %lu is not set up\n", 42 41 axis); 43 42 return; 44 43 } ··· 50 49 } 51 50 52 51 /** 53 - * touchscreen_parse_properties - parse common touchscreen DT properties 52 + * touchscreen_parse_properties - parse common touchscreen properties 54 53 * @input: input device that should be parsed 55 54 * @multitouch: specifies whether parsed properties should be applied to 56 55 * single-touch or multi-touch axes ··· 58 57 * axis swap and invert info for use with touchscreen_report_x_y(); 59 58 * or %NULL 60 59 * 61 - * This function parses common DT properties for touchscreens and setups the 60 + * This function parses common properties for touchscreens and sets up the 62 61 * input device accordingly. The function keeps previously set up default 63 - * values if no value is specified via DT. 62 + * values if no value is specified. 64 63 */ 65 64 void touchscreen_parse_properties(struct input_dev *input, bool multitouch, 66 65 struct touchscreen_properties *prop) ··· 204 203 EXPORT_SYMBOL(touchscreen_report_pos); 205 204 206 205 MODULE_LICENSE("GPL v2"); 207 - MODULE_DESCRIPTION("Device-tree helpers functions for touchscreen devices"); 206 + MODULE_DESCRIPTION("Helper functions for touchscreens and other devices");
+41 -5
drivers/input/touchscreen/silead.c
··· 20 20 #include <linux/input/mt.h> 21 21 #include <linux/input/touchscreen.h> 22 22 #include <linux/pm.h> 23 + #include <linux/pm_runtime.h> 23 24 #include <linux/irq.h> 24 25 #include <linux/regulator/consumer.h> 25 26 ··· 336 335 337 336 error = i2c_smbus_read_i2c_block_data(client, SILEAD_REG_ID, 338 337 sizeof(chip_id), (u8 *)&chip_id); 339 - if (error < 0) { 340 - dev_err(&client->dev, "Chip ID read error %d\n", error); 338 + if (error < 0) 341 339 return error; 342 - } 343 340 344 341 data->chip_id = le32_to_cpu(chip_id); 345 342 dev_info(&client->dev, "Silead chip ID: 0x%8X", data->chip_id); ··· 350 351 int error; 351 352 u32 status; 352 353 354 + /* 355 + * Some buggy BIOS-es bring up the chip in a stuck state where it 356 + * blocks the I2C bus. The following steps are necessary to 357 + * unstuck the chip / bus: 358 + * 1. Turn off the Silead chip. 359 + * 2. Try to do an I2C transfer with the chip, this will fail in 360 + * response to which the I2C-bus-driver will call: 361 + * i2c_recover_bus() which will unstuck the I2C-bus. Note the 362 + * unstuck-ing of the I2C bus only works if we first drop the 363 + * chip off the bus by turning it off. 364 + * 3. Turn the chip back on. 365 + * 366 + * On the x86/ACPI systems were this problem is seen, step 1. and 367 + * 3. require making ACPI calls and dealing with ACPI Power 368 + * Resources. The workaround below runtime-suspends the chip to 369 + * turn it off, leaving it up to the ACPI subsystem to deal with 370 + * this. 371 + */ 372 + 373 + if (device_property_read_bool(&client->dev, 374 + "silead,stuck-controller-bug")) { 375 + pm_runtime_set_active(&client->dev); 376 + pm_runtime_enable(&client->dev); 377 + pm_runtime_allow(&client->dev); 378 + 379 + pm_runtime_suspend(&client->dev); 380 + 381 + dev_warn(&client->dev, FW_BUG "Stuck I2C bus: please ignore the next 'controller timed out' error\n"); 382 + silead_ts_get_id(client); 383 + 384 + /* The forbid will also resume the device */ 385 + pm_runtime_forbid(&client->dev); 386 + pm_runtime_disable(&client->dev); 387 + } 388 + 353 389 silead_ts_set_power(client, SILEAD_POWER_OFF); 354 390 silead_ts_set_power(client, SILEAD_POWER_ON); 355 391 356 392 error = silead_ts_get_id(client); 357 - if (error) 393 + if (error) { 394 + dev_err(&client->dev, "Chip ID read error %d\n", error); 358 395 return error; 396 + } 359 397 360 398 error = silead_ts_init(client); 361 399 if (error) ··· 522 486 523 487 silead_ts_read_props(client); 524 488 525 - /* We must have the IRQ provided by DT or ACPI subsytem */ 489 + /* We must have the IRQ provided by DT or ACPI subsystem */ 526 490 if (client->irq <= 0) 527 491 return -ENODEV; 528 492
+1 -2
drivers/input/touchscreen/stmfts.c
··· 691 691 * interrupts. To be on the safe side it's better to not enable 692 692 * the interrupts during their request. 693 693 */ 694 - irq_set_status_flags(client->irq, IRQ_NOAUTOEN); 695 694 err = devm_request_threaded_irq(&client->dev, client->irq, 696 695 NULL, stmfts_irq_handler, 697 - IRQF_ONESHOT, 696 + IRQF_ONESHOT | IRQF_NO_AUTOEN, 698 697 "stmfts_irq", sdata); 699 698 if (err) 700 699 return err;
+3 -1
drivers/input/touchscreen/tsc2007.h
··· 19 19 #ifndef _TSC2007_H 20 20 #define _TSC2007_H 21 21 22 + struct gpio_desc; 23 + 22 24 #define TSC2007_MEASURE_TEMP0 (0x0 << 4) 23 25 #define TSC2007_MEASURE_AUX (0x2 << 4) 24 26 #define TSC2007_MEASURE_TEMP1 (0x4 << 4) ··· 71 69 int fuzzy; 72 70 int fuzzz; 73 71 74 - unsigned int gpio; 72 + struct gpio_desc *gpiod; 75 73 int irq; 76 74 77 75 wait_queue_head_t wait;
+23 -37
drivers/input/touchscreen/tsc2007_core.c
··· 19 19 20 20 #include <linux/module.h> 21 21 #include <linux/slab.h> 22 + #include <linux/gpio/consumer.h> 22 23 #include <linux/input.h> 23 24 #include <linux/interrupt.h> 24 25 #include <linux/i2c.h> 25 - #include <linux/of_device.h> 26 - #include <linux/of_gpio.h> 26 + #include <linux/mod_devicetable.h> 27 + #include <linux/property.h> 27 28 #include <linux/platform_data/tsc2007.h> 28 29 #include "tsc2007.h" 29 30 ··· 221 220 tsc2007_stop(ts); 222 221 } 223 222 224 - #ifdef CONFIG_OF 225 223 static int tsc2007_get_pendown_state_gpio(struct device *dev) 226 224 { 227 225 struct i2c_client *client = to_i2c_client(dev); 228 226 struct tsc2007 *ts = i2c_get_clientdata(client); 229 227 230 - return !gpio_get_value(ts->gpio); 228 + return gpiod_get_value(ts->gpiod); 231 229 } 232 230 233 - static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts) 231 + static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts) 234 232 { 235 - struct device_node *np = client->dev.of_node; 236 233 u32 val32; 237 234 u64 val64; 238 235 239 - if (!np) { 240 - dev_err(&client->dev, "missing device tree data\n"); 241 - return -EINVAL; 242 - } 243 - 244 - if (!of_property_read_u32(np, "ti,max-rt", &val32)) 236 + if (!device_property_read_u32(dev, "ti,max-rt", &val32)) 245 237 ts->max_rt = val32; 246 238 else 247 239 ts->max_rt = MAX_12BIT; 248 240 249 - if (!of_property_read_u32(np, "ti,fuzzx", &val32)) 241 + if (!device_property_read_u32(dev, "ti,fuzzx", &val32)) 250 242 ts->fuzzx = val32; 251 243 252 - if (!of_property_read_u32(np, "ti,fuzzy", &val32)) 244 + if (!device_property_read_u32(dev, "ti,fuzzy", &val32)) 253 245 ts->fuzzy = val32; 254 246 255 - if (!of_property_read_u32(np, "ti,fuzzz", &val32)) 247 + if (!device_property_read_u32(dev, "ti,fuzzz", &val32)) 256 248 ts->fuzzz = val32; 257 249 258 - if (!of_property_read_u64(np, "ti,poll-period", &val64)) 250 + if (!device_property_read_u64(dev, "ti,poll-period", &val64)) 259 251 ts->poll_period = msecs_to_jiffies(val64); 260 252 else 261 253 ts->poll_period = msecs_to_jiffies(1); 262 254 263 - if (!of_property_read_u32(np, "ti,x-plate-ohms", &val32)) { 255 + if (!device_property_read_u32(dev, "ti,x-plate-ohms", &val32)) { 264 256 ts->x_plate_ohms = val32; 265 257 } else { 266 - dev_err(&client->dev, "missing ti,x-plate-ohms devicetree property."); 258 + dev_err(dev, "Missing ti,x-plate-ohms device property\n"); 267 259 return -EINVAL; 268 260 } 269 261 270 - ts->gpio = of_get_gpio(np, 0); 271 - if (gpio_is_valid(ts->gpio)) 262 + ts->gpiod = devm_gpiod_get_optional(dev, NULL, GPIOD_IN); 263 + if (IS_ERR(ts->gpiod)) 264 + return PTR_ERR(ts->gpiod); 265 + 266 + if (ts->gpiod) 272 267 ts->get_pendown_state = tsc2007_get_pendown_state_gpio; 273 268 else 274 - dev_warn(&client->dev, 275 - "GPIO not specified in DT (of_get_gpio returned %d)\n", 276 - ts->gpio); 269 + dev_warn(dev, "Pen down GPIO is not specified in properties\n"); 277 270 278 271 return 0; 279 272 } 280 - #else 281 - static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts) 282 - { 283 - dev_err(&client->dev, "platform data is required!\n"); 284 - return -EINVAL; 285 - } 286 - #endif 287 273 288 - static int tsc2007_probe_pdev(struct i2c_client *client, struct tsc2007 *ts, 274 + static int tsc2007_probe_pdev(struct device *dev, struct tsc2007 *ts, 289 275 const struct tsc2007_platform_data *pdata, 290 276 const struct i2c_device_id *id) 291 277 { ··· 287 299 ts->fuzzz = pdata->fuzzz; 288 300 289 301 if (pdata->x_plate_ohms == 0) { 290 - dev_err(&client->dev, "x_plate_ohms is not set up in platform data"); 302 + dev_err(dev, "x_plate_ohms is not set up in platform data\n"); 291 303 return -EINVAL; 292 304 } 293 305 ··· 320 332 return -ENOMEM; 321 333 322 334 if (pdata) 323 - err = tsc2007_probe_pdev(client, ts, pdata, id); 335 + err = tsc2007_probe_pdev(&client->dev, ts, pdata, id); 324 336 else 325 - err = tsc2007_probe_dt(client, ts); 337 + err = tsc2007_probe_properties(&client->dev, ts); 326 338 if (err) 327 339 return err; 328 340 ··· 419 431 420 432 MODULE_DEVICE_TABLE(i2c, tsc2007_idtable); 421 433 422 - #ifdef CONFIG_OF 423 434 static const struct of_device_id tsc2007_of_match[] = { 424 435 { .compatible = "ti,tsc2007" }, 425 436 { /* sentinel */ } 426 437 }; 427 438 MODULE_DEVICE_TABLE(of, tsc2007_of_match); 428 - #endif 429 439 430 440 static struct i2c_driver tsc2007_driver = { 431 441 .driver = { 432 442 .name = "tsc2007", 433 - .of_match_table = of_match_ptr(tsc2007_of_match), 443 + .of_match_table = tsc2007_of_match, 434 444 }, 435 445 .id_table = tsc2007_idtable, 436 446 .probe = tsc2007_probe,
+17 -39
drivers/input/touchscreen/wacom_i2c.c
··· 145 145 } 146 146 147 147 static int wacom_i2c_probe(struct i2c_client *client, 148 - const struct i2c_device_id *id) 148 + const struct i2c_device_id *id) 149 149 { 150 + struct device *dev = &client->dev; 150 151 struct wacom_i2c *wac_i2c; 151 152 struct input_dev *input; 152 153 struct wacom_features features = { 0 }; 153 154 int error; 154 155 155 156 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { 156 - dev_err(&client->dev, "i2c_check_functionality error\n"); 157 + dev_err(dev, "i2c_check_functionality error\n"); 157 158 return -EIO; 158 159 } 159 160 ··· 162 161 if (error) 163 162 return error; 164 163 165 - wac_i2c = kzalloc(sizeof(*wac_i2c), GFP_KERNEL); 166 - input = input_allocate_device(); 167 - if (!wac_i2c || !input) { 168 - error = -ENOMEM; 169 - goto err_free_mem; 170 - } 164 + wac_i2c = devm_kzalloc(dev, sizeof(*wac_i2c), GFP_KERNEL); 165 + if (!wac_i2c) 166 + return -ENOMEM; 171 167 172 168 wac_i2c->client = client; 169 + 170 + input = devm_input_allocate_device(dev); 171 + if (!input) 172 + return -ENOMEM; 173 + 173 174 wac_i2c->input = input; 174 175 175 176 input->name = "Wacom I2C Digitizer"; 176 177 input->id.bustype = BUS_I2C; 177 178 input->id.vendor = 0x56a; 178 179 input->id.version = features.fw_version; 179 - input->dev.parent = &client->dev; 180 180 input->open = wacom_i2c_open; 181 181 input->close = wacom_i2c_close; 182 182 ··· 196 194 197 195 input_set_drvdata(input, wac_i2c); 198 196 199 - error = request_threaded_irq(client->irq, NULL, wacom_i2c_irq, 200 - IRQF_TRIGGER_LOW | IRQF_ONESHOT, 201 - "wacom_i2c", wac_i2c); 197 + error = devm_request_threaded_irq(dev, client->irq, NULL, wacom_i2c_irq, 198 + IRQF_ONESHOT, "wacom_i2c", wac_i2c); 202 199 if (error) { 203 - dev_err(&client->dev, 204 - "Failed to enable IRQ, error: %d\n", error); 205 - goto err_free_mem; 200 + dev_err(dev, "Failed to request IRQ: %d\n", error); 201 + return error; 206 202 } 207 203 208 204 /* Disable the IRQ, we'll enable it in wac_i2c_open() */ ··· 208 208 209 209 error = input_register_device(wac_i2c->input); 210 210 if (error) { 211 - dev_err(&client->dev, 212 - "Failed to register input device, error: %d\n", error); 213 - goto err_free_irq; 211 + dev_err(dev, "Failed to register input device: %d\n", error); 212 + return error; 214 213 } 215 - 216 - i2c_set_clientdata(client, wac_i2c); 217 - return 0; 218 - 219 - err_free_irq: 220 - free_irq(client->irq, wac_i2c); 221 - err_free_mem: 222 - input_free_device(input); 223 - kfree(wac_i2c); 224 - 225 - return error; 226 - } 227 - 228 - static int wacom_i2c_remove(struct i2c_client *client) 229 - { 230 - struct wacom_i2c *wac_i2c = i2c_get_clientdata(client); 231 - 232 - free_irq(client->irq, wac_i2c); 233 - input_unregister_device(wac_i2c->input); 234 - kfree(wac_i2c); 235 214 236 215 return 0; 237 216 } ··· 248 269 }, 249 270 250 271 .probe = wacom_i2c_probe, 251 - .remove = wacom_i2c_remove, 252 272 .id_table = wacom_i2c_id, 253 273 }; 254 274 module_i2c_driver(wacom_i2c_driver);
+1 -2
drivers/input/touchscreen/wm831x-ts.c
··· 317 317 318 318 error = request_threaded_irq(wm831x_ts->data_irq, 319 319 NULL, wm831x_ts_data_irq, 320 - irqf | IRQF_ONESHOT, 320 + irqf | IRQF_ONESHOT | IRQF_NO_AUTOEN, 321 321 "Touchscreen data", wm831x_ts); 322 322 if (error) { 323 323 dev_err(&pdev->dev, "Failed to request data IRQ %d: %d\n", 324 324 wm831x_ts->data_irq, error); 325 325 goto err_alloc; 326 326 } 327 - disable_irq(wm831x_ts->data_irq); 328 327 329 328 if (pdata && pdata->pd_irqf) 330 329 irqf = pdata->pd_irqf;
+2 -2
drivers/input/touchscreen/zinitix.c
··· 513 513 return -EINVAL; 514 514 } 515 515 516 - irq_set_status_flags(client->irq, IRQ_NOAUTOEN); 517 516 error = devm_request_threaded_irq(&client->dev, client->irq, 518 517 NULL, zinitix_ts_irq_handler, 519 - IRQF_ONESHOT, client->name, bt541); 518 + IRQF_ONESHOT | IRQF_NO_AUTOEN, 519 + client->name, bt541); 520 520 if (error) { 521 521 dev_err(&client->dev, "Failed to request IRQ: %d\n", error); 522 522 return error;
+10
include/dt-bindings/input/atmel-maxtouch.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 + 3 + #ifndef _DT_BINDINGS_ATMEL_MAXTOUCH_H 4 + #define _DT_BINDINGS_ATMEL_MAXTOUCH_H 5 + 6 + #define ATMEL_MXT_WAKEUP_NONE 0 7 + #define ATMEL_MXT_WAKEUP_I2C_SCL 1 8 + #define ATMEL_MXT_WAKEUP_GPIO 2 9 + 10 + #endif /* _DT_BINDINGS_ATMEL_MAXTOUCH_H */