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

Merge tag 'input-for-v6.6-rc0' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input

Pull input updates from Dmitry Torokhov:

- a new driver for Azoteq IQS7210A/7211A/E touch controllers

- support for Azoteq IQS7222D variant added to iqs7222 driver

- support for touch keys functionality added to Melfas MMS114 driver

- new hardware IDs added to exc3000 and Goodix drivers

- xpad driver gained support for GameSir T4 Kaleid Controller

- a fix for xpad driver to properly support some third-party
controllers that need a magic packet to start properly

- a fix for psmouse driver to more reliably switch to RMI4 mode on
devices that use native RMI4/SMbus protocol

- a quirk for i8042 for TUXEDO Gemini 17 Gen1/Clevo PD70PN laptops

- multiple drivers have been updated to make use of devm and other
newer APIs such as dev_err_probe(), devm_regulator_get_enable(), and
others.

* tag 'input-for-v6.6-rc0' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (83 commits)
Input: goodix - add support for ACPI ID GDX9110
Input: rpckbd - fix the return value handle for platform_get_irq()
Input: tca6416-keypad - switch to using input core's polling features
Input: tca6416-keypad - convert to use devm_* api
Input: tca6416-keypad - fix interrupt enable disbalance
Input: tca6416-keypad - rely on I2C core to set up suspend/resume
Input: tca6416-keypad - always expect proper IRQ number in i2c client
Input: lm8323 - convert to use devm_* api
Input: lm8323 - rely on device core to create kp_disable attribute
Input: qt2160 - convert to use devm_* api
Input: qt2160 - do not hard code interrupt trigger
Input: qt2160 - switch to using threaded interrupt handler
Input: qt2160 - tweak check for i2c adapter functionality
Input: psmouse - add delay when deactivating for SMBus mode
Input: mcs-touchkey - fix uninitialized use of error in mcs_touchkey_probe()
Input: qt1070 - convert to use devm_* api
Input: mcs-touchkey - convert to use devm_* api
Input: amikbd - convert to use devm_* api
Input: lm8333 - convert to use devm_* api
Input: mms114 - add support for touch keys
...

+4643 -1055
+223 -25
Documentation/devicetree/bindings/input/azoteq,iqs7222.yaml
··· 4 4 $id: http://devicetree.org/schemas/input/azoteq,iqs7222.yaml# 5 5 $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 - title: Azoteq IQS7222A/B/C Capacitive Touch Controller 7 + title: Azoteq IQS7222A/B/C/D Capacitive Touch Controller 8 8 9 9 maintainers: 10 10 - Jeff LaBundy <jeff@labundy.com> 11 11 12 12 description: | 13 - The Azoteq IQS7222A, IQS7222B and IQS7222C are multichannel capacitive touch 14 - controllers that feature additional sensing capabilities. 13 + The Azoteq IQS7222A, IQS7222B, IQS7222C and IQS7222D are multichannel 14 + capacitive touch controllers that feature additional sensing capabilities. 15 15 16 16 Link to datasheets: https://www.azoteq.com/ 17 17 ··· 21 21 - azoteq,iqs7222a 22 22 - azoteq,iqs7222b 23 23 - azoteq,iqs7222c 24 + - azoteq,iqs7222d 24 25 25 26 reg: 26 27 maxItems: 1 ··· 174 173 maximum: 3000 175 174 description: Specifies the report rate (in ms) during ultra-low-power mode. 176 175 176 + touchscreen-size-x: true 177 + touchscreen-size-y: true 178 + touchscreen-inverted-x: true 179 + touchscreen-inverted-y: true 180 + touchscreen-swapped-x-y: true 181 + 182 + trackpad: 183 + type: object 184 + description: Represents all channels associated with the trackpad. 185 + 186 + properties: 187 + azoteq,channel-select: 188 + $ref: /schemas/types.yaml#/definitions/uint32-array 189 + minItems: 1 190 + maxItems: 12 191 + items: 192 + minimum: 0 193 + maximum: 13 194 + description: 195 + Specifies the order of the channels that participate in the trackpad. 196 + Specify 255 to omit a given channel for the purpose of mapping a non- 197 + rectangular trackpad. 198 + 199 + azoteq,num-rows: 200 + $ref: /schemas/types.yaml#/definitions/uint32 201 + minimum: 1 202 + maximum: 12 203 + description: Specifies the number of rows that comprise the trackpad. 204 + 205 + azoteq,num-cols: 206 + $ref: /schemas/types.yaml#/definitions/uint32 207 + minimum: 1 208 + maximum: 12 209 + description: Specifies the number of columns that comprise the trackpad. 210 + 211 + azoteq,top-speed: 212 + $ref: /schemas/types.yaml#/definitions/uint32 213 + multipleOf: 4 214 + minimum: 0 215 + maximum: 1020 216 + description: 217 + Specifies the speed (in coordinates traveled per conversion) after 218 + which coordinate filtering is no longer applied. 219 + 220 + azoteq,bottom-speed: 221 + $ref: /schemas/types.yaml#/definitions/uint32 222 + minimum: 0 223 + maximum: 255 224 + description: 225 + Specifies the speed (in coordinates traveled per conversion) after 226 + which coordinate filtering is linearly reduced. 227 + 228 + azoteq,use-prox: 229 + type: boolean 230 + description: 231 + Directs the trackpad to respond to the proximity states of the 232 + selected channels instead of their corresponding touch states. 233 + Note the trackpad cannot report granular coordinates during a 234 + state of proximity. 235 + 236 + patternProperties: 237 + "^azoteq,lower-cal-(x|y)$": 238 + $ref: /schemas/types.yaml#/definitions/uint32 239 + minimum: 0 240 + maximum: 255 241 + description: Specifies the trackpad's lower starting points. 242 + 243 + "^azoteq,upper-cal-(x|y)$": 244 + $ref: /schemas/types.yaml#/definitions/uint32 245 + minimum: 0 246 + maximum: 255 247 + description: Specifies the trackpad's upper starting points. 248 + 249 + "^event-(press|tap|(swipe|flick)-(x|y)-(pos|neg))$": 250 + type: object 251 + $ref: input.yaml# 252 + description: 253 + Represents a press or gesture event reported by the trackpad. Specify 254 + 'linux,code' under the press event to report absolute coordinates. 255 + 256 + properties: 257 + linux,code: true 258 + 259 + azoteq,gesture-angle-tighten: 260 + type: boolean 261 + description: 262 + Limits the tangent of the gesture angle to 0.5 (axial gestures 263 + only). If specified in one direction, the effect is applied in 264 + either direction. 265 + 266 + azoteq,gesture-max-ms: 267 + multipleOf: 16 268 + minimum: 0 269 + maximum: 4080 270 + description: 271 + Specifies the length of time (in ms) within which a tap, swipe 272 + or flick gesture must be completed in order to be acknowledged 273 + by the device. The number specified for any one swipe or flick 274 + gesture applies to all other swipe or flick gestures. 275 + 276 + azoteq,gesture-min-ms: 277 + multipleOf: 16 278 + minimum: 0 279 + maximum: 4080 280 + description: 281 + Specifies the length of time (in ms) for which a tap gesture must 282 + be held in order to be acknowledged by the device. 283 + 284 + azoteq,gesture-dist: 285 + $ref: /schemas/types.yaml#/definitions/uint32 286 + minimum: 0 287 + maximum: 65535 288 + description: 289 + Specifies the distance (in coordinates) across which a swipe or 290 + flick gesture must travel in order to be acknowledged by the 291 + device. The number specified for any one swipe or flick gesture 292 + applies to all remaining swipe or flick gestures. 293 + 294 + For tap gestures, this property specifies the distance from the 295 + original point of contact across which the contact is permitted 296 + to travel before the gesture is rejected by the device. 297 + 298 + azoteq,gpio-select: 299 + $ref: /schemas/types.yaml#/definitions/uint32-array 300 + minItems: 1 301 + maxItems: 3 302 + items: 303 + minimum: 0 304 + maximum: 2 305 + description: | 306 + Specifies one or more GPIO mapped to the event as follows: 307 + 0: GPIO0 308 + 1: GPIO3 309 + 2: GPIO4 310 + 311 + Note that although multiple events can be mapped to a single 312 + GPIO, they must all be of the same type (proximity, touch or 313 + trackpad gesture). 314 + 315 + additionalProperties: false 316 + 317 + required: 318 + - azoteq,channel-select 319 + 320 + additionalProperties: false 321 + 177 322 patternProperties: 178 323 "^cycle-[0-9]$": 179 324 type: object ··· 434 287 description: 435 288 Activates the reference channel in response to proximity events 436 289 instead of touch events. 290 + 291 + azoteq,counts-filt-enable: 292 + type: boolean 293 + description: Applies counts filtering to the channel. 437 294 438 295 azoteq,ati-band: 439 296 $ref: /schemas/types.yaml#/definitions/uint32 ··· 583 432 description: | 584 433 Specifies one or more GPIO mapped to the event as follows: 585 434 0: GPIO0 586 - 1: GPIO3 (IQS7222C only) 587 - 2: GPIO4 (IQS7222C only) 435 + 1: GPIO3 436 + 2: GPIO4 588 437 589 438 Note that although multiple events can be mapped to a single 590 439 GPIO, they must all be of the same type (proximity, touch or 591 - slider gesture). 440 + slider/trackpad gesture). 592 441 593 442 azoteq,thresh: 594 443 $ref: /schemas/types.yaml#/definitions/uint32 ··· 672 521 minimum: 0 673 522 maximum: 65535 674 523 description: 675 - Specifies the speed of movement after which coordinate filtering is 676 - no longer applied. 524 + Specifies the speed (in coordinates traveled per conversion) after 525 + which coordinate filtering is no longer applied. 677 526 678 527 azoteq,bottom-speed: 679 528 $ref: /schemas/types.yaml#/definitions/uint32 680 529 minimum: 0 681 530 maximum: 255 682 531 description: 683 - Specifies the speed of movement after which coordinate filtering is 684 - linearly reduced. 532 + Specifies the speed (in coordinates traveled per conversion) after 533 + which coordinate filtering is linearly reduced. 685 534 686 535 azoteq,bottom-beta: 687 536 $ref: /schemas/types.yaml#/definitions/uint32 ··· 746 595 minimum: 0 747 596 maximum: 4080 748 597 description: 749 - Specifies the distance across which a swipe or flick gesture must 750 - travel in order to be acknowledged by the device. The number spec- 751 - ified for any one swipe or flick gesture applies to all remaining 752 - swipe or flick gestures. 598 + Specifies the distance (in coordinates) across which a swipe or 599 + flick gesture must travel in order to be acknowledged by the 600 + device. The number specified for any one swipe or flick gesture 601 + applies to all remaining swipe or flick gestures. 753 602 754 603 azoteq,gpio-select: 755 604 $ref: /schemas/types.yaml#/definitions/uint32-array ··· 761 610 description: | 762 611 Specifies one or more GPIO mapped to the event as follows: 763 612 0: GPIO0 764 - 1: GPIO3 (IQS7222C only) 765 - 2: GPIO4 (IQS7222C only) 613 + 1: GPIO3 614 + 2: GPIO4 766 615 767 616 Note that although multiple events can be mapped to a single 768 617 GPIO, they must all be of the same type (proximity, touch or ··· 780 629 description: | 781 630 Represents a GPIO mapped to one or more events as follows: 782 631 gpio-0: GPIO0 783 - gpio-1: GPIO3 (IQS7222C only) 784 - gpio-2: GPIO4 (IQS7222C only) 632 + gpio-1: GPIO3 633 + gpio-2: GPIO4 785 634 786 635 allOf: 787 636 - $ref: ../pinctrl/pincfg-node.yaml# ··· 792 641 additionalProperties: false 793 642 794 643 allOf: 644 + - $ref: touchscreen/touchscreen.yaml# 645 + 795 646 - if: 796 647 properties: 797 648 compatible: 798 649 contains: 799 - const: azoteq,iqs7222b 650 + enum: 651 + - azoteq,iqs7222a 652 + - azoteq,iqs7222b 653 + - azoteq,iqs7222c 654 + 655 + then: 656 + properties: 657 + touchscreen-size-x: false 658 + touchscreen-size-y: false 659 + touchscreen-inverted-x: false 660 + touchscreen-inverted-y: false 661 + touchscreen-swapped-x-y: false 662 + 663 + trackpad: false 664 + 665 + patternProperties: 666 + "^channel-([0-9]|1[0-9])$": 667 + properties: 668 + azoteq,counts-filt-enable: false 669 + 670 + - if: 671 + properties: 672 + compatible: 673 + contains: 674 + enum: 675 + - azoteq,iqs7222b 676 + - azoteq,iqs7222c 677 + 678 + then: 679 + patternProperties: 680 + "^channel-([0-9]|1[0-9])$": 681 + properties: 682 + azoteq,ulp-allow: false 683 + 684 + - if: 685 + properties: 686 + compatible: 687 + contains: 688 + enum: 689 + - azoteq,iqs7222b 690 + - azoteq,iqs7222d 800 691 801 692 then: 802 693 patternProperties: ··· 850 657 properties: 851 658 azoteq,ref-select: false 852 659 660 + "^slider-[0-1]$": false 661 + 662 + - if: 663 + properties: 664 + compatible: 665 + contains: 666 + const: azoteq,iqs7222b 667 + 668 + then: 669 + patternProperties: 670 + "^channel-([0-9]|1[0-9])$": 853 671 patternProperties: 854 672 "^event-(prox|touch)$": 855 673 properties: 856 674 azoteq,gpio-select: false 857 - 858 - "^slider-[0-1]$": false 859 675 860 676 "^gpio-[0-2]$": false 861 677 ··· 906 704 907 705 else: 908 706 patternProperties: 909 - "^channel-([0-9]|1[0-9])$": 910 - properties: 911 - azoteq,ulp-allow: false 912 - 913 707 "^slider-[0-1]$": 914 708 patternProperties: 915 709 "^event-(press|tap|(swipe|flick)-(pos|neg))$":
+769
Documentation/devicetree/bindings/input/touchscreen/azoteq,iqs7211.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/azoteq,iqs7211.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Azoteq IQS7210A/7211A/E Trackpad/Touchscreen Controller 8 + 9 + maintainers: 10 + - Jeff LaBundy <jeff@labundy.com> 11 + 12 + description: | 13 + The Azoteq IQS7210A, IQS7211A and IQS7211E trackpad and touchscreen control- 14 + lers employ projected-capacitance sensing and can track two contacts. 15 + 16 + Link to datasheets: https://www.azoteq.com/ 17 + 18 + properties: 19 + compatible: 20 + enum: 21 + - azoteq,iqs7210a 22 + - azoteq,iqs7211a 23 + - azoteq,iqs7211e 24 + 25 + reg: 26 + maxItems: 1 27 + 28 + irq-gpios: 29 + maxItems: 1 30 + description: 31 + Specifies the GPIO connected to the device's active-low RDY output. The 32 + pin doubles as the IQS7211E's active-low MCLR input, in which case this 33 + GPIO must be configured as open-drain. 34 + 35 + reset-gpios: 36 + maxItems: 1 37 + description: 38 + Specifies the GPIO connected to the device's active-low MCLR input. The 39 + device is temporarily held in hardware reset prior to initialization if 40 + this property is present. 41 + 42 + azoteq,forced-comms: 43 + type: boolean 44 + description: 45 + Enables forced communication; to be used with host adapters that cannot 46 + tolerate clock stretching. 47 + 48 + azoteq,forced-comms-default: 49 + $ref: /schemas/types.yaml#/definitions/uint32 50 + enum: [0, 1] 51 + description: 52 + Indicates if the device's OTP memory enables (1) or disables (0) forced 53 + communication by default. Specifying this property can expedite startup 54 + time if the default value is known. 55 + 56 + If this property is not specified, communication is not initiated until 57 + the device asserts its RDY pin shortly after exiting hardware reset. At 58 + that point, forced communication is either enabled or disabled based on 59 + the presence or absence of the 'azoteq,forced-comms' property. 60 + 61 + azoteq,rate-active-ms: 62 + minimum: 0 63 + maximum: 65535 64 + description: Specifies the report rate (in ms) during active mode. 65 + 66 + azoteq,rate-touch-ms: 67 + minimum: 0 68 + maximum: 65535 69 + description: Specifies the report rate (in ms) during idle-touch mode. 70 + 71 + azoteq,rate-idle-ms: 72 + minimum: 0 73 + maximum: 65535 74 + description: Specifies the report rate (in ms) during idle mode. 75 + 76 + azoteq,rate-lp1-ms: 77 + minimum: 0 78 + maximum: 65535 79 + description: Specifies the report rate (in ms) during low-power mode 1. 80 + 81 + azoteq,rate-lp2-ms: 82 + minimum: 0 83 + maximum: 65535 84 + description: Specifies the report rate (in ms) during low-power mode 2. 85 + 86 + azoteq,timeout-active-ms: 87 + multipleOf: 1000 88 + minimum: 0 89 + maximum: 65535000 90 + description: 91 + Specifies the length of time (in ms) to wait for an event before moving 92 + from active mode to idle or idle-touch modes. 93 + 94 + azoteq,timeout-touch-ms: 95 + multipleOf: 1000 96 + minimum: 0 97 + maximum: 65535000 98 + description: 99 + Specifies the length of time (in ms) to wait for an event before moving 100 + from idle-touch mode to idle mode. 101 + 102 + azoteq,timeout-idle-ms: 103 + multipleOf: 1000 104 + minimum: 0 105 + maximum: 65535000 106 + description: 107 + Specifies the length of time (in ms) to wait for an event before moving 108 + from idle mode to low-power mode 1. 109 + 110 + azoteq,timeout-lp1-ms: 111 + multipleOf: 1000 112 + minimum: 0 113 + maximum: 65535000 114 + description: 115 + Specifies the length of time (in ms) to wait for an event before moving 116 + from low-power mode 1 to low-power mode 2. 117 + 118 + azoteq,timeout-lp2-ms: 119 + multipleOf: 1000 120 + minimum: 0 121 + maximum: 60000 122 + description: 123 + Specifies the rate (in ms) at which the trackpad reference values 124 + are updated during low-power modes 1 and 2. 125 + 126 + azoteq,timeout-ati-ms: 127 + multipleOf: 1000 128 + minimum: 0 129 + maximum: 60000 130 + description: 131 + Specifies the delay (in ms) before the automatic tuning implementation 132 + (ATI) is retried in the event it fails to complete. 133 + 134 + azoteq,timeout-comms-ms: 135 + minimum: 0 136 + maximum: 65535 137 + description: 138 + Specifies the delay (in ms) before a communication window is closed. 139 + 140 + azoteq,timeout-press-ms: 141 + multipleOf: 1000 142 + minimum: 0 143 + maximum: 60000 144 + description: 145 + Specifies the length of time (in ms) to wait before automatically 146 + releasing a press event. Specify zero to allow the press state to 147 + persist indefinitely. 148 + 149 + azoteq,fosc-freq: 150 + $ref: /schemas/types.yaml#/definitions/uint32 151 + enum: [0, 1] 152 + description: | 153 + Specifies the device's core clock frequency as follows: 154 + 0: 14 MHz 155 + 1: 18 MHz 156 + 157 + azoteq,fosc-trim: 158 + $ref: /schemas/types.yaml#/definitions/uint32 159 + minimum: 0 160 + maximum: 15 161 + description: Specifies the device's core clock frequency trim. 162 + 163 + azoteq,num-contacts: 164 + $ref: /schemas/types.yaml#/definitions/uint32 165 + minimum: 0 166 + maximum: 2 167 + default: 0 168 + description: Specifies the number of contacts reported by the device. 169 + 170 + azoteq,contact-split: 171 + $ref: /schemas/types.yaml#/definitions/uint32 172 + minimum: 0 173 + maximum: 255 174 + description: Specifies the contact (finger) split factor. 175 + 176 + azoteq,trim-x: 177 + $ref: /schemas/types.yaml#/definitions/uint32 178 + minimum: 0 179 + maximum: 255 180 + description: Specifies the horizontal trim width. 181 + 182 + azoteq,trim-y: 183 + $ref: /schemas/types.yaml#/definitions/uint32 184 + minimum: 0 185 + maximum: 255 186 + description: Specifies the vertical trim height. 187 + 188 + trackpad: 189 + type: object 190 + description: Represents all channels associated with the trackpad. 191 + 192 + properties: 193 + azoteq,rx-enable: 194 + $ref: /schemas/types.yaml#/definitions/uint32-array 195 + minItems: 1 196 + maxItems: 8 197 + items: 198 + minimum: 0 199 + maximum: 7 200 + description: 201 + Specifies the order of the CRx pin(s) associated with the trackpad. 202 + 203 + azoteq,tx-enable: 204 + $ref: /schemas/types.yaml#/definitions/uint32-array 205 + minItems: 1 206 + maxItems: 12 207 + items: 208 + minimum: 0 209 + maximum: 11 210 + description: 211 + Specifies the order of the CTx pin(s) associated with the trackpad. 212 + 213 + azoteq,channel-select: 214 + $ref: /schemas/types.yaml#/definitions/uint32-array 215 + minItems: 1 216 + maxItems: 36 217 + items: 218 + minimum: 0 219 + maximum: 255 220 + description: | 221 + Specifies the channels mapped to each cycle in the following order: 222 + Cycle 0, slot 0 223 + Cycle 0, slot 1 224 + Cycle 1, slot 0 225 + Cycle 1, slot 1 226 + ...and so on. Specify 255 to disable a given slot. 227 + 228 + azoteq,ati-frac-div-fine: 229 + $ref: /schemas/types.yaml#/definitions/uint32 230 + minimum: 0 231 + maximum: 31 232 + description: Specifies the trackpad's ATI fine fractional divider. 233 + 234 + azoteq,ati-frac-mult-coarse: 235 + $ref: /schemas/types.yaml#/definitions/uint32 236 + minimum: 0 237 + maximum: 15 238 + description: Specifies the trackpad's ATI coarse fractional multiplier. 239 + 240 + azoteq,ati-frac-div-coarse: 241 + $ref: /schemas/types.yaml#/definitions/uint32 242 + minimum: 0 243 + maximum: 31 244 + description: Specifies the trackpad's ATI coarse fractional divider. 245 + 246 + azoteq,ati-comp-div: 247 + $ref: /schemas/types.yaml#/definitions/uint32 248 + minimum: 0 249 + maximum: 31 250 + description: Specifies the trackpad's ATI compensation divider. 251 + 252 + azoteq,ati-target: 253 + $ref: /schemas/types.yaml#/definitions/uint32 254 + minimum: 0 255 + maximum: 65535 256 + description: Specifies the trackpad's ATI target. 257 + 258 + azoteq,touch-enter: 259 + $ref: /schemas/types.yaml#/definitions/uint32 260 + minimum: 0 261 + maximum: 255 262 + description: Specifies the trackpad's touch entrance factor. 263 + 264 + azoteq,touch-exit: 265 + $ref: /schemas/types.yaml#/definitions/uint32 266 + minimum: 0 267 + maximum: 255 268 + description: Specifies the trackpad's touch exit factor. 269 + 270 + azoteq,thresh: 271 + $ref: /schemas/types.yaml#/definitions/uint32 272 + minimum: 0 273 + maximum: 255 274 + description: Specifies the trackpad's stationary touch threshold. 275 + 276 + azoteq,conv-period: 277 + $ref: /schemas/types.yaml#/definitions/uint32 278 + minimum: 0 279 + maximum: 255 280 + description: Specifies the trackpad's conversion period. 281 + 282 + azoteq,conv-frac: 283 + $ref: /schemas/types.yaml#/definitions/uint32 284 + minimum: 0 285 + maximum: 255 286 + description: Specifies the trackpad's conversion frequency fraction. 287 + 288 + patternProperties: 289 + "^event-(tap(-double|-triple)?|hold|palm|swipe-(x|y)-(pos|neg)(-hold)?)$": 290 + type: object 291 + $ref: ../input.yaml# 292 + description: 293 + Represents a gesture event reported by the trackpad. In the case of 294 + axial gestures, the duration or distance specified in one direction 295 + applies to both directions along the same axis. 296 + 297 + properties: 298 + linux,code: true 299 + 300 + azoteq,gesture-max-ms: 301 + minimum: 0 302 + maximum: 65535 303 + description: Specifies the maximum duration of tap/swipe gestures. 304 + 305 + azoteq,gesture-mid-ms: 306 + minimum: 0 307 + maximum: 65535 308 + description: 309 + Specifies the maximum duration between subsequent tap gestures 310 + (IQS7211E only). 311 + 312 + azoteq,gesture-min-ms: 313 + minimum: 0 314 + maximum: 65535 315 + description: Specifies the minimum duration of hold gestures. 316 + 317 + azoteq,gesture-dist: 318 + $ref: /schemas/types.yaml#/definitions/uint32 319 + minimum: 0 320 + maximum: 65535 321 + description: 322 + Specifies the minimum (swipe) or maximum (tap and hold) distance 323 + a finger may travel to be considered a gesture. 324 + 325 + azoteq,gesture-dist-rep: 326 + $ref: /schemas/types.yaml#/definitions/uint32 327 + minimum: 0 328 + maximum: 65535 329 + description: 330 + Specifies the minimum distance a finger must travel to elicit a 331 + repeated swipe gesture (IQS7211E only). 332 + 333 + azoteq,gesture-angle: 334 + $ref: /schemas/types.yaml#/definitions/uint32 335 + minimum: 0 336 + maximum: 75 337 + description: 338 + Specifies the maximum angle (in degrees) a finger may travel to 339 + be considered a swipe gesture. 340 + 341 + azoteq,thresh: 342 + $ref: /schemas/types.yaml#/definitions/uint32 343 + minimum: 0 344 + maximum: 42 345 + description: Specifies the palm gesture threshold (IQS7211E only). 346 + 347 + additionalProperties: false 348 + 349 + dependencies: 350 + azoteq,rx-enable: ["azoteq,tx-enable"] 351 + azoteq,tx-enable: ["azoteq,rx-enable"] 352 + azoteq,channel-select: ["azoteq,rx-enable"] 353 + 354 + additionalProperties: false 355 + 356 + alp: 357 + type: object 358 + $ref: ../input.yaml# 359 + description: Represents the alternate low-power channel (ALP). 360 + 361 + properties: 362 + azoteq,rx-enable: 363 + $ref: /schemas/types.yaml#/definitions/uint32-array 364 + minItems: 1 365 + maxItems: 8 366 + items: 367 + minimum: 0 368 + maximum: 7 369 + description: 370 + Specifies the CRx pin(s) associated with the ALP in no particular 371 + order. 372 + 373 + azoteq,tx-enable: 374 + $ref: /schemas/types.yaml#/definitions/uint32-array 375 + minItems: 1 376 + maxItems: 12 377 + items: 378 + minimum: 0 379 + maximum: 11 380 + description: 381 + Specifies the CTx pin(s) associated with the ALP in no particular 382 + order. 383 + 384 + azoteq,ati-frac-div-fine: 385 + $ref: /schemas/types.yaml#/definitions/uint32 386 + minimum: 0 387 + maximum: 31 388 + description: Specifies the ALP's ATI fine fractional divider. 389 + 390 + azoteq,ati-frac-mult-coarse: 391 + $ref: /schemas/types.yaml#/definitions/uint32 392 + minimum: 0 393 + maximum: 15 394 + description: Specifies the ALP's ATI coarse fractional multiplier. 395 + 396 + azoteq,ati-frac-div-coarse: 397 + $ref: /schemas/types.yaml#/definitions/uint32 398 + minimum: 0 399 + maximum: 31 400 + description: Specifies the ALP's ATI coarse fractional divider. 401 + 402 + azoteq,ati-comp-div: 403 + $ref: /schemas/types.yaml#/definitions/uint32 404 + minimum: 0 405 + maximum: 31 406 + description: Specifies the ALP's ATI compensation divider. 407 + 408 + azoteq,ati-target: 409 + $ref: /schemas/types.yaml#/definitions/uint32 410 + minimum: 0 411 + maximum: 65535 412 + description: Specifies the ALP's ATI target. 413 + 414 + azoteq,ati-base: 415 + $ref: /schemas/types.yaml#/definitions/uint32 416 + multipleOf: 8 417 + minimum: 0 418 + maximum: 255 419 + description: Specifies the ALP's ATI base. 420 + 421 + azoteq,ati-mode: 422 + $ref: /schemas/types.yaml#/definitions/uint32 423 + enum: [0, 1] 424 + description: | 425 + Specifies the ALP's ATI mode as follows: 426 + 0: Partial 427 + 1: Full 428 + 429 + azoteq,sense-mode: 430 + $ref: /schemas/types.yaml#/definitions/uint32 431 + enum: [0, 1] 432 + description: | 433 + Specifies the ALP's sensing mode as follows: 434 + 0: Self capacitive 435 + 1: Mutual capacitive 436 + 437 + azoteq,debounce-enter: 438 + $ref: /schemas/types.yaml#/definitions/uint32 439 + minimum: 0 440 + maximum: 255 441 + description: Specifies the ALP's debounce entrance factor. 442 + 443 + azoteq,debounce-exit: 444 + $ref: /schemas/types.yaml#/definitions/uint32 445 + minimum: 0 446 + maximum: 255 447 + description: Specifies the ALP's debounce exit factor. 448 + 449 + azoteq,thresh: 450 + $ref: /schemas/types.yaml#/definitions/uint32 451 + minimum: 0 452 + maximum: 65535 453 + description: Specifies the ALP's proximity or touch threshold. 454 + 455 + azoteq,conv-period: 456 + $ref: /schemas/types.yaml#/definitions/uint32 457 + minimum: 0 458 + maximum: 255 459 + description: Specifies the ALP's conversion period. 460 + 461 + azoteq,conv-frac: 462 + $ref: /schemas/types.yaml#/definitions/uint32 463 + minimum: 0 464 + maximum: 255 465 + description: Specifies the ALP's conversion frequency fraction. 466 + 467 + linux,code: true 468 + 469 + additionalProperties: false 470 + 471 + button: 472 + type: object 473 + description: Represents the inductive or capacitive button. 474 + 475 + properties: 476 + azoteq,ati-frac-div-fine: 477 + $ref: /schemas/types.yaml#/definitions/uint32 478 + minimum: 0 479 + maximum: 31 480 + description: Specifies the button's ATI fine fractional divider. 481 + 482 + azoteq,ati-frac-mult-coarse: 483 + $ref: /schemas/types.yaml#/definitions/uint32 484 + minimum: 0 485 + maximum: 15 486 + description: Specifies the button's ATI coarse fractional multiplier. 487 + 488 + azoteq,ati-frac-div-coarse: 489 + $ref: /schemas/types.yaml#/definitions/uint32 490 + minimum: 0 491 + maximum: 31 492 + description: Specifies the button's ATI coarse fractional divider. 493 + 494 + azoteq,ati-comp-div: 495 + $ref: /schemas/types.yaml#/definitions/uint32 496 + minimum: 0 497 + maximum: 31 498 + description: Specifies the button's ATI compensation divider. 499 + 500 + azoteq,ati-target: 501 + $ref: /schemas/types.yaml#/definitions/uint32 502 + minimum: 0 503 + maximum: 65535 504 + description: Specifies the button's ATI target. 505 + 506 + azoteq,ati-base: 507 + $ref: /schemas/types.yaml#/definitions/uint32 508 + multipleOf: 8 509 + minimum: 0 510 + maximum: 255 511 + description: Specifies the button's ATI base. 512 + 513 + azoteq,ati-mode: 514 + $ref: /schemas/types.yaml#/definitions/uint32 515 + enum: [0, 1] 516 + description: | 517 + Specifies the button's ATI mode as follows: 518 + 0: Partial 519 + 1: Full 520 + 521 + azoteq,sense-mode: 522 + $ref: /schemas/types.yaml#/definitions/uint32 523 + enum: [0, 1, 2] 524 + description: | 525 + Specifies the button's sensing mode as follows: 526 + 0: Self capacitive 527 + 1: Mutual capacitive 528 + 2: Inductive 529 + 530 + azoteq,touch-enter: 531 + $ref: /schemas/types.yaml#/definitions/uint32 532 + minimum: 0 533 + maximum: 255 534 + description: Specifies the button's touch entrance factor. 535 + 536 + azoteq,touch-exit: 537 + $ref: /schemas/types.yaml#/definitions/uint32 538 + minimum: 0 539 + maximum: 255 540 + description: Specifies the button's touch exit factor. 541 + 542 + azoteq,debounce-enter: 543 + $ref: /schemas/types.yaml#/definitions/uint32 544 + minimum: 0 545 + maximum: 255 546 + description: Specifies the button's debounce entrance factor. 547 + 548 + azoteq,debounce-exit: 549 + $ref: /schemas/types.yaml#/definitions/uint32 550 + minimum: 0 551 + maximum: 255 552 + description: Specifies the button's debounce exit factor. 553 + 554 + azoteq,thresh: 555 + $ref: /schemas/types.yaml#/definitions/uint32 556 + minimum: 0 557 + maximum: 65535 558 + description: Specifies the button's proximity threshold. 559 + 560 + azoteq,conv-period: 561 + $ref: /schemas/types.yaml#/definitions/uint32 562 + minimum: 0 563 + maximum: 255 564 + description: Specifies the button's conversion period. 565 + 566 + azoteq,conv-frac: 567 + $ref: /schemas/types.yaml#/definitions/uint32 568 + minimum: 0 569 + maximum: 255 570 + description: Specifies the button's conversion frequency fraction. 571 + 572 + patternProperties: 573 + "^event-(prox|touch)$": 574 + type: object 575 + $ref: ../input.yaml# 576 + description: 577 + Represents a proximity or touch event reported by the button. 578 + 579 + properties: 580 + linux,code: true 581 + 582 + additionalProperties: false 583 + 584 + additionalProperties: false 585 + 586 + wakeup-source: true 587 + 588 + touchscreen-size-x: true 589 + touchscreen-size-y: true 590 + touchscreen-inverted-x: true 591 + touchscreen-inverted-y: true 592 + touchscreen-swapped-x-y: true 593 + 594 + dependencies: 595 + touchscreen-size-x: ["azoteq,num-contacts"] 596 + touchscreen-size-y: ["azoteq,num-contacts"] 597 + touchscreen-inverted-x: ["azoteq,num-contacts"] 598 + touchscreen-inverted-y: ["azoteq,num-contacts"] 599 + touchscreen-swapped-x-y: ["azoteq,num-contacts"] 600 + 601 + required: 602 + - compatible 603 + - reg 604 + - irq-gpios 605 + 606 + additionalProperties: false 607 + 608 + allOf: 609 + - $ref: touchscreen.yaml# 610 + 611 + - if: 612 + properties: 613 + compatible: 614 + contains: 615 + const: azoteq,iqs7210a 616 + 617 + then: 618 + properties: 619 + alp: 620 + properties: 621 + azoteq,rx-enable: 622 + maxItems: 4 623 + items: 624 + minimum: 4 625 + 626 + else: 627 + properties: 628 + azoteq,timeout-press-ms: false 629 + 630 + alp: 631 + properties: 632 + azoteq,ati-mode: false 633 + 634 + button: false 635 + 636 + - if: 637 + properties: 638 + compatible: 639 + contains: 640 + const: azoteq,iqs7211e 641 + 642 + then: 643 + properties: 644 + reset-gpios: false 645 + 646 + trackpad: 647 + properties: 648 + azoteq,tx-enable: 649 + maxItems: 13 650 + items: 651 + maximum: 12 652 + 653 + alp: 654 + properties: 655 + azoteq,tx-enable: 656 + maxItems: 13 657 + items: 658 + maximum: 12 659 + 660 + examples: 661 + - | 662 + #include <dt-bindings/gpio/gpio.h> 663 + #include <dt-bindings/input/input.h> 664 + 665 + i2c { 666 + #address-cells = <1>; 667 + #size-cells = <0>; 668 + 669 + touch@56 { 670 + compatible = "azoteq,iqs7210a"; 671 + reg = <0x56>; 672 + irq-gpios = <&gpio 4 GPIO_ACTIVE_LOW>; 673 + reset-gpios = <&gpio 17 (GPIO_ACTIVE_LOW | 674 + GPIO_PUSH_PULL)>; 675 + azoteq,num-contacts = <2>; 676 + 677 + trackpad { 678 + azoteq,rx-enable = <6>, <5>, <4>, <3>, <2>; 679 + azoteq,tx-enable = <1>, <7>, <8>, <9>, <10>; 680 + }; 681 + 682 + button { 683 + azoteq,sense-mode = <2>; 684 + azoteq,touch-enter = <40>; 685 + azoteq,touch-exit = <36>; 686 + 687 + event-touch { 688 + linux,code = <KEY_HOME>; 689 + }; 690 + }; 691 + 692 + alp { 693 + azoteq,sense-mode = <1>; 694 + linux,code = <KEY_POWER>; 695 + }; 696 + }; 697 + }; 698 + 699 + - | 700 + #include <dt-bindings/gpio/gpio.h> 701 + #include <dt-bindings/input/input.h> 702 + 703 + i2c { 704 + #address-cells = <1>; 705 + #size-cells = <0>; 706 + 707 + touch@56 { 708 + compatible = "azoteq,iqs7211e"; 709 + reg = <0x56>; 710 + irq-gpios = <&gpio 4 (GPIO_ACTIVE_LOW | 711 + GPIO_OPEN_DRAIN)>; 712 + 713 + trackpad { 714 + event-tap { 715 + linux,code = <KEY_PLAYPAUSE>; 716 + }; 717 + 718 + event-tap-double { 719 + linux,code = <KEY_SHUFFLE>; 720 + }; 721 + 722 + event-tap-triple { 723 + linux,code = <KEY_AGAIN>; 724 + }; 725 + 726 + event-hold { 727 + linux,code = <KEY_STOP>; 728 + }; 729 + 730 + event-palm { 731 + linux,code = <KEY_EXIT>; 732 + }; 733 + 734 + event-swipe-x-pos { 735 + linux,code = <KEY_REWIND>; 736 + }; 737 + 738 + event-swipe-x-pos-hold { 739 + linux,code = <KEY_PREVIOUS>; 740 + }; 741 + 742 + event-swipe-x-neg { 743 + linux,code = <KEY_FASTFORWARD>; 744 + }; 745 + 746 + event-swipe-x-neg-hold { 747 + linux,code = <KEY_NEXT>; 748 + }; 749 + 750 + event-swipe-y-pos { 751 + linux,code = <KEY_VOLUMEUP>; 752 + }; 753 + 754 + event-swipe-y-pos-hold { 755 + linux,code = <KEY_MUTE>; 756 + }; 757 + 758 + event-swipe-y-neg { 759 + linux,code = <KEY_VOLUMEDOWN>; 760 + }; 761 + 762 + event-swipe-y-neg-hold { 763 + linux,code = <KEY_MUTE>; 764 + }; 765 + }; 766 + }; 767 + }; 768 + 769 + ...
+6
Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.yaml
··· 93 93 minimum: 1 94 94 maximum: 255 95 95 96 + threshold: 97 + description: Allows setting the "click"-threshold in the range from 0 to 255. 98 + $ref: /schemas/types.yaml#/definitions/uint32 99 + minimum: 0 100 + maximum: 255 101 + 96 102 touchscreen-size-x: true 97 103 touchscreen-size-y: true 98 104 touchscreen-fuzz-x: true
+2
Documentation/devicetree/bindings/input/touchscreen/eeti,exc3000.yaml
··· 24 24 maxItems: 1 25 25 reset-gpios: 26 26 maxItems: 1 27 + vdd-supply: 28 + description: Power supply regulator for the chip 27 29 touchscreen-size-x: true 28 30 touchscreen-size-y: true 29 31 touchscreen-inverted-x: true
+5
Documentation/devicetree/bindings/input/touchscreen/melfas,mms114.yaml
··· 52 52 touchscreen-swapped-x-y: true 53 53 touchscreen-max-pressure: true 54 54 55 + linux,keycodes: 56 + description: Keycodes for the touch keys 57 + minItems: 1 58 + maxItems: 15 59 + 55 60 additionalProperties: false 56 61 57 62 required:
+3 -1
drivers/input/gameport/Kconfig
··· 25 25 26 26 config GAMEPORT_NS558 27 27 tristate "Classic ISA and PnP gameport support" 28 + depends on ISA 28 29 help 29 30 Say Y here if you have an ISA or PnP gameport. 30 31 ··· 36 35 37 36 config GAMEPORT_L4 38 37 tristate "PDPI Lightning 4 gamecard support" 38 + depends on ISA 39 39 help 40 40 Say Y here if you have a PDPI Lightning 4 gamecard. 41 41 ··· 55 53 56 54 config GAMEPORT_FM801 57 55 tristate "ForteMedia FM801 gameport support" 58 - depends on PCI 56 + depends on PCI && HAS_IOPORT 59 57 help 60 58 Say Y here if you have ForteMedia FM801 PCI audio controller 61 59 (Abit AU10, Genius Sound Maker, HP Workstation zx2000,
+21 -5
drivers/input/gameport/gameport.c
··· 519 519 520 520 static void gameport_default_trigger(struct gameport *gameport) 521 521 { 522 + #ifdef CONFIG_HAS_IOPORT 522 523 outb(0xff, gameport->io); 524 + #endif 523 525 } 524 526 525 527 static unsigned char gameport_default_read(struct gameport *gameport) 526 528 { 529 + #ifdef CONFIG_HAS_IOPORT 527 530 return inb(gameport->io); 531 + #else 532 + return 0xff; 533 + #endif 534 + } 535 + 536 + static void gameport_setup_default_handlers(struct gameport *gameport) 537 + { 538 + if ((!gameport->trigger || !gameport->read) && 539 + !IS_ENABLED(CONFIG_HAS_IOPORT)) 540 + dev_err(&gameport->dev, 541 + "I/O port access is required for %s (%s) but is not available\n", 542 + gameport->phys, gameport->name); 543 + 544 + if (!gameport->trigger) 545 + gameport->trigger = gameport_default_trigger; 546 + if (!gameport->read) 547 + gameport->read = gameport_default_read; 528 548 } 529 549 530 550 /* ··· 565 545 if (gameport->parent) 566 546 gameport->dev.parent = &gameport->parent->dev; 567 547 568 - if (!gameport->trigger) 569 - gameport->trigger = gameport_default_trigger; 570 - if (!gameport->read) 571 - gameport->read = gameport_default_read; 572 - 548 + gameport_setup_default_handlers(gameport); 573 549 INIT_LIST_HEAD(&gameport->node); 574 550 spin_lock_init(&gameport->timer_lock); 575 551 timer_setup(&gameport->poll_timer, gameport_run_poll_handler, 0);
+25
drivers/input/joystick/xpad.c
··· 264 264 { 0x0f0d, 0x0067, "HORIPAD ONE", 0, XTYPE_XBOXONE }, 265 265 { 0x0f0d, 0x0078, "Hori Real Arcade Pro V Kai Xbox One", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, 266 266 { 0x0f0d, 0x00c5, "Hori Fighting Commander ONE", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, 267 + { 0x0f0d, 0x00dc, "HORIPAD FPS for Nintendo Switch", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, 267 268 { 0x0f30, 0x010b, "Philips Recoil", 0, XTYPE_XBOX }, 268 269 { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX }, 269 270 { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX }, ··· 366 365 { 0x31e3, 0x1300, "Wooting 60HE (AVR)", 0, XTYPE_XBOX360 }, 367 366 { 0x31e3, 0x1310, "Wooting 60HE (ARM)", 0, XTYPE_XBOX360 }, 368 367 { 0x3285, 0x0607, "Nacon GC-100", 0, XTYPE_XBOX360 }, 368 + { 0x3537, 0x1004, "GameSir T4 Kaleid", 0, XTYPE_XBOX360 }, 369 369 { 0x3767, 0x0101, "Fanatec Speedster 3 Forceshock Wheel", 0, XTYPE_XBOX }, 370 370 { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX }, 371 371 { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN } ··· 501 499 XPAD_XBOX360_VENDOR(0x2f24), /* GameSir controllers */ 502 500 XPAD_XBOX360_VENDOR(0x31e3), /* Wooting Keyboards */ 503 501 XPAD_XBOX360_VENDOR(0x3285), /* Nacon GC-100 */ 502 + XPAD_XBOX360_VENDOR(0x3537), /* GameSir Controllers */ 503 + XPAD_XBOXONE_VENDOR(0x3537), /* GameSir Controllers */ 504 504 { } 505 505 }; 506 506 ··· 1723 1719 usb_kill_urb(xpad->irq_in); 1724 1720 return error; 1725 1721 } 1722 + } 1723 + if (xpad->xtype == XTYPE_XBOX360) { 1724 + /* 1725 + * Some third-party controllers Xbox 360-style controllers 1726 + * require this message to finish initialization. 1727 + */ 1728 + u8 dummy[20]; 1729 + 1730 + error = usb_control_msg_recv(xpad->udev, 0, 1731 + /* bRequest */ 0x01, 1732 + /* bmRequestType */ 1733 + USB_TYPE_VENDOR | USB_DIR_IN | 1734 + USB_RECIP_INTERFACE, 1735 + /* wValue */ 0x100, 1736 + /* wIndex */ 0x00, 1737 + dummy, sizeof(dummy), 1738 + 25, GFP_KERNEL); 1739 + if (error) 1740 + dev_warn(&xpad->dev->dev, 1741 + "unable to receive magic message: %d\n", 1742 + error); 1726 1743 } 1727 1744 1728 1745 return 0;
+1 -16
drivers/input/keyboard/adp5588-keys.c
··· 713 713 return 0; 714 714 } 715 715 716 - static void adp5588_disable_regulator(void *reg) 717 - { 718 - regulator_disable(reg); 719 - } 720 - 721 716 static int adp5588_probe(struct i2c_client *client) 722 717 { 723 718 struct adp5588_kpad *kpad; 724 719 struct input_dev *input; 725 720 struct gpio_desc *gpio; 726 - struct regulator *vcc; 727 721 unsigned int revid; 728 722 int ret; 729 723 int error; ··· 743 749 if (error) 744 750 return error; 745 751 746 - vcc = devm_regulator_get(&client->dev, "vcc"); 747 - if (IS_ERR(vcc)) 748 - return PTR_ERR(vcc); 749 - 750 - error = regulator_enable(vcc); 751 - if (error) 752 - return error; 753 - 754 - error = devm_add_action_or_reset(&client->dev, 755 - adp5588_disable_regulator, vcc); 752 + error = devm_regulator_get_enable(&client->dev, "vcc"); 756 753 if (error) 757 754 return error; 758 755
+5 -20
drivers/input/keyboard/amikbd.c
··· 196 196 struct input_dev *dev; 197 197 int i, err; 198 198 199 - dev = input_allocate_device(); 199 + dev = devm_input_allocate_device(&pdev->dev); 200 200 if (!dev) { 201 201 dev_err(&pdev->dev, "Not enough memory for input device\n"); 202 202 return -ENOMEM; ··· 208 208 dev->id.vendor = 0x0001; 209 209 dev->id.product = 0x0001; 210 210 dev->id.version = 0x0100; 211 - dev->dev.parent = &pdev->dev; 212 211 213 212 dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); 214 213 ··· 217 218 amikbd_init_console_keymaps(); 218 219 219 220 ciaa.cra &= ~0x41; /* serial data in, turn off TA */ 220 - err = request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd", 221 - dev); 221 + err = devm_request_irq(&pdev->dev, IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 222 + 0, "amikbd", dev); 222 223 if (err) 223 - goto fail2; 224 + return err; 224 225 225 226 err = input_register_device(dev); 226 227 if (err) 227 - goto fail3; 228 + return err; 228 229 229 230 platform_set_drvdata(pdev, dev); 230 231 231 232 return 0; 232 - 233 - fail3: free_irq(IRQ_AMIGA_CIAA_SP, dev); 234 - fail2: input_free_device(dev); 235 - return err; 236 - } 237 - 238 - static int __exit amikbd_remove(struct platform_device *pdev) 239 - { 240 - struct input_dev *dev = platform_get_drvdata(pdev); 241 - 242 - free_irq(IRQ_AMIGA_CIAA_SP, dev); 243 - input_unregister_device(dev); 244 - return 0; 245 233 } 246 234 247 235 static struct platform_driver amikbd_driver = { 248 - .remove = __exit_p(amikbd_remove), 249 236 .driver = { 250 237 .name = "amiga-keyboard", 251 238 },
+5 -19
drivers/input/keyboard/bcm-keypad.c
··· 307 307 { 308 308 struct bcm_kp *kp; 309 309 struct input_dev *input_dev; 310 - struct resource *res; 311 310 int error; 312 311 313 312 kp = devm_kzalloc(&pdev->dev, sizeof(*kp), GFP_KERNEL); ··· 352 353 return error; 353 354 } 354 355 355 - /* Get the KEYPAD base address */ 356 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 357 - if (!res) { 358 - dev_err(&pdev->dev, "Missing keypad base address resource\n"); 359 - return -ENODEV; 360 - } 361 - 362 - kp->base = devm_ioremap_resource(&pdev->dev, res); 356 + kp->base = devm_platform_ioremap_resource(pdev, 0); 363 357 if (IS_ERR(kp->base)) 364 358 return PTR_ERR(kp->base); 365 359 366 360 /* Enable clock */ 367 - kp->clk = devm_clk_get(&pdev->dev, "peri_clk"); 361 + kp->clk = devm_clk_get_optional(&pdev->dev, "peri_clk"); 368 362 if (IS_ERR(kp->clk)) { 369 - error = PTR_ERR(kp->clk); 370 - if (error != -ENOENT) { 371 - if (error != -EPROBE_DEFER) 372 - dev_err(&pdev->dev, "Failed to get clock\n"); 373 - return error; 374 - } 375 - dev_dbg(&pdev->dev, 376 - "No clock specified. Assuming it's enabled\n"); 377 - kp->clk = NULL; 363 + return dev_err_probe(&pdev->dev, PTR_ERR(kp->clk), "Failed to get clock\n"); 364 + } else if (!kp->clk) { 365 + dev_dbg(&pdev->dev, "No clock specified. Assuming it's enabled\n"); 378 366 } else { 379 367 unsigned int desired_rate; 380 368 long actual_rate;
+9 -12
drivers/input/keyboard/gpio_keys.c
··· 523 523 NULL, GPIOD_IN, desc); 524 524 if (IS_ERR(bdata->gpiod)) { 525 525 error = PTR_ERR(bdata->gpiod); 526 - if (error == -ENOENT) { 527 - /* 528 - * GPIO is optional, we may be dealing with 529 - * purely interrupt-driven setup. 530 - */ 531 - bdata->gpiod = NULL; 532 - } else { 533 - if (error != -EPROBE_DEFER) 534 - dev_err(dev, "failed to get gpio: %d\n", 535 - error); 536 - return error; 537 - } 526 + if (error != -ENOENT) 527 + return dev_err_probe(dev, error, 528 + "failed to get gpio\n"); 529 + 530 + /* 531 + * GPIO is optional, we may be dealing with 532 + * purely interrupt-driven setup. 533 + */ 534 + bdata->gpiod = NULL; 538 535 } 539 536 } else if (gpio_is_valid(button->gpio)) { 540 537 /*
+2 -6
drivers/input/keyboard/gpio_keys_polled.c
··· 299 299 NULL, GPIOD_IN, 300 300 button->desc); 301 301 if (IS_ERR(bdata->gpiod)) { 302 - error = PTR_ERR(bdata->gpiod); 303 - if (error != -EPROBE_DEFER) 304 - dev_err(dev, 305 - "failed to get gpio: %d\n", 306 - error); 307 302 fwnode_handle_put(child); 308 - return error; 303 + return dev_err_probe(dev, PTR_ERR(bdata->gpiod), 304 + "failed to get gpio\n"); 309 305 } 310 306 } else if (gpio_is_valid(button->gpio)) { 311 307 /*
+35 -60
drivers/input/keyboard/lm8323.c
··· 556 556 const char *name) 557 557 { 558 558 struct lm8323_pwm *pwm; 559 + int err; 559 560 560 561 BUG_ON(id > 3); 561 562 ··· 576 575 pwm->cdev.name = name; 577 576 pwm->cdev.brightness_set = lm8323_pwm_set_brightness; 578 577 pwm->cdev.groups = lm8323_pwm_groups; 579 - if (led_classdev_register(dev, &pwm->cdev) < 0) { 580 - dev_err(dev, "couldn't register PWM %d\n", id); 581 - return -1; 578 + 579 + err = devm_led_classdev_register(dev, &pwm->cdev); 580 + if (err) { 581 + dev_err(dev, "couldn't register PWM %d: %d\n", id, err); 582 + return err; 582 583 } 583 584 pwm->enabled = true; 584 585 } 585 586 586 587 return 0; 587 588 } 588 - 589 - static struct i2c_driver lm8323_i2c_driver; 590 589 591 590 static ssize_t lm8323_show_disable(struct device *dev, 592 591 struct device_attribute *attr, char *buf) ··· 616 615 } 617 616 static DEVICE_ATTR(disable_kp, 0644, lm8323_show_disable, lm8323_set_disable); 618 617 618 + static struct attribute *lm8323_attrs[] = { 619 + &dev_attr_disable_kp.attr, 620 + NULL, 621 + }; 622 + ATTRIBUTE_GROUPS(lm8323); 623 + 619 624 static int lm8323_probe(struct i2c_client *client) 620 625 { 621 626 struct lm8323_platform_data *pdata = dev_get_platdata(&client->dev); ··· 649 642 return -EINVAL; 650 643 } 651 644 652 - lm = kzalloc(sizeof *lm, GFP_KERNEL); 653 - idev = input_allocate_device(); 654 - if (!lm || !idev) { 655 - err = -ENOMEM; 656 - goto fail1; 657 - } 645 + lm = devm_kzalloc(&client->dev, sizeof(*lm), GFP_KERNEL); 646 + if (!lm) 647 + return -ENOMEM; 648 + 649 + idev = devm_input_allocate_device(&client->dev); 650 + if (!idev) 651 + return -ENOMEM; 658 652 659 653 lm->client = client; 660 654 lm->idev = idev; ··· 671 663 672 664 lm8323_reset(lm); 673 665 674 - /* Nothing's set up to service the IRQ yet, so just spin for max. 675 - * 100ms until we can configure. */ 666 + /* 667 + * Nothing's set up to service the IRQ yet, so just spin for max. 668 + * 100ms until we can configure. 669 + */ 676 670 tmo = jiffies + msecs_to_jiffies(100); 677 671 while (lm8323_read(lm, LM8323_CMD_READ_INT, data, 1) == 1) { 678 672 if (data[0] & INT_NOINIT) ··· 694 684 /* If a true probe check the device */ 695 685 if (lm8323_read_id(lm, data) != 0) { 696 686 dev_err(&client->dev, "device not found\n"); 697 - err = -ENODEV; 698 - goto fail1; 687 + return -ENODEV; 699 688 } 700 689 701 690 for (pwm = 0; pwm < LM8323_NUM_PWMS; pwm++) { 702 691 err = init_pwm(lm, pwm + 1, &client->dev, 703 692 pdata->pwm_names[pwm]); 704 - if (err < 0) 705 - goto fail2; 693 + if (err) 694 + return err; 706 695 } 707 696 708 697 lm->kp_enabled = true; 709 - err = device_create_file(&client->dev, &dev_attr_disable_kp); 710 - if (err < 0) 711 - goto fail2; 712 698 713 699 idev->name = pdata->name ? : "LM8323 keypad"; 714 700 snprintf(lm->phys, sizeof(lm->phys), ··· 725 719 err = input_register_device(idev); 726 720 if (err) { 727 721 dev_dbg(&client->dev, "error registering input device\n"); 728 - goto fail3; 722 + return err; 729 723 } 730 724 731 - err = request_threaded_irq(client->irq, NULL, lm8323_irq, 732 - IRQF_TRIGGER_LOW|IRQF_ONESHOT, "lm8323", lm); 725 + err = devm_request_threaded_irq(&client->dev, client->irq, 726 + NULL, lm8323_irq, 727 + IRQF_TRIGGER_LOW | IRQF_ONESHOT, 728 + "lm8323", lm); 733 729 if (err) { 734 730 dev_err(&client->dev, "could not get IRQ %d\n", client->irq); 735 - goto fail4; 731 + return err; 736 732 } 737 733 738 734 i2c_set_clientdata(client, lm); ··· 743 735 enable_irq_wake(client->irq); 744 736 745 737 return 0; 746 - 747 - fail4: 748 - input_unregister_device(idev); 749 - idev = NULL; 750 - fail3: 751 - device_remove_file(&client->dev, &dev_attr_disable_kp); 752 - fail2: 753 - while (--pwm >= 0) 754 - if (lm->pwm[pwm].enabled) 755 - led_classdev_unregister(&lm->pwm[pwm].cdev); 756 - fail1: 757 - input_free_device(idev); 758 - kfree(lm); 759 - return err; 760 - } 761 - 762 - static void lm8323_remove(struct i2c_client *client) 763 - { 764 - struct lm8323_chip *lm = i2c_get_clientdata(client); 765 - int i; 766 - 767 - disable_irq_wake(client->irq); 768 - free_irq(client->irq, lm); 769 - 770 - input_unregister_device(lm->idev); 771 - 772 - device_remove_file(&lm->client->dev, &dev_attr_disable_kp); 773 - 774 - for (i = 0; i < 3; i++) 775 - if (lm->pwm[i].enabled) 776 - led_classdev_unregister(&lm->pwm[i].cdev); 777 - 778 - kfree(lm); 779 738 } 780 739 781 740 /* ··· 798 823 799 824 static struct i2c_driver lm8323_i2c_driver = { 800 825 .driver = { 801 - .name = "lm8323", 802 - .pm = pm_sleep_ptr(&lm8323_pm_ops), 826 + .name = "lm8323", 827 + .pm = pm_sleep_ptr(&lm8323_pm_ops), 828 + .dev_groups = lm8323_groups, 803 829 }, 804 830 .probe = lm8323_probe, 805 - .remove = lm8323_remove, 806 831 .id_table = lm8323_id, 807 832 }; 808 833 MODULE_DEVICE_TABLE(i2c, lm8323_id);
+14 -30
drivers/input/keyboard/lm8333.c
··· 142 142 return -EINVAL; 143 143 } 144 144 145 - lm8333 = kzalloc(sizeof(*lm8333), GFP_KERNEL); 146 - input = input_allocate_device(); 147 - if (!lm8333 || !input) { 148 - err = -ENOMEM; 149 - goto free_mem; 150 - } 145 + lm8333 = devm_kzalloc(&client->dev, sizeof(*lm8333), GFP_KERNEL); 146 + if (!lm8333) 147 + return -ENOMEM; 148 + 149 + input = devm_input_allocate_device(&client->dev); 150 + if (!input) 151 + return -ENOMEM; 151 152 152 153 lm8333->client = client; 153 154 lm8333->input = input; 154 155 155 156 input->name = client->name; 156 - input->dev.parent = &client->dev; 157 157 input->id.bustype = BUS_I2C; 158 158 159 159 input_set_capability(input, EV_MSC, MSC_SCAN); ··· 162 162 LM8333_NUM_ROWS, LM8333_NUM_COLS, 163 163 lm8333->keycodes, input); 164 164 if (err) 165 - goto free_mem; 165 + return err; 166 166 167 167 if (pdata->debounce_time) { 168 168 err = lm8333_write8(lm8333, LM8333_DEBOUNCE, ··· 178 178 dev_warn(&client->dev, "Unable to set active time\n"); 179 179 } 180 180 181 - err = request_threaded_irq(client->irq, NULL, lm8333_irq_thread, 182 - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 183 - "lm8333", lm8333); 181 + err = devm_request_threaded_irq(&client->dev, client->irq, 182 + NULL, lm8333_irq_thread, 183 + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 184 + "lm8333", lm8333); 184 185 if (err) 185 - goto free_mem; 186 + return err; 186 187 187 188 err = input_register_device(input); 188 189 if (err) 189 - goto free_irq; 190 + return err; 190 191 191 192 i2c_set_clientdata(client, lm8333); 192 193 return 0; 193 - 194 - free_irq: 195 - free_irq(client->irq, lm8333); 196 - free_mem: 197 - input_free_device(input); 198 - kfree(lm8333); 199 - return err; 200 - } 201 - 202 - static void lm8333_remove(struct i2c_client *client) 203 - { 204 - struct lm8333 *lm8333 = i2c_get_clientdata(client); 205 - 206 - free_irq(client->irq, lm8333); 207 - input_unregister_device(lm8333->input); 208 - kfree(lm8333); 209 194 } 210 195 211 196 static const struct i2c_device_id lm8333_id[] = { ··· 204 219 .name = "lm8333", 205 220 }, 206 221 .probe = lm8333_probe, 207 - .remove = lm8333_remove, 208 222 .id_table = lm8333_id, 209 223 }; 210 224 module_i2c_driver(lm8333_driver);
+1 -8
drivers/input/keyboard/lpc32xx-keys.c
··· 160 160 { 161 161 struct lpc32xx_kscan_drv *kscandat; 162 162 struct input_dev *input; 163 - struct resource *res; 164 163 size_t keymap_size; 165 164 int error; 166 165 int irq; 167 - 168 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 169 - if (!res) { 170 - dev_err(&pdev->dev, "failed to get platform I/O memory\n"); 171 - return -EINVAL; 172 - } 173 166 174 167 irq = platform_get_irq(pdev, 0); 175 168 if (irq < 0) ··· 214 221 215 222 input_set_drvdata(kscandat->input, kscandat); 216 223 217 - kscandat->kscan_base = devm_ioremap_resource(&pdev->dev, res); 224 + kscandat->kscan_base = devm_platform_ioremap_resource(pdev, 0); 218 225 if (IS_ERR(kscandat->kscan_base)) 219 226 return PTR_ERR(kscandat->kscan_base); 220 227
+30 -35
drivers/input/keyboard/mcs_touchkey.c
··· 92 92 return IRQ_HANDLED; 93 93 } 94 94 95 + static void mcs_touchkey_poweroff(void *data) 96 + { 97 + struct mcs_touchkey_data *touchkey = data; 98 + 99 + touchkey->poweron(false); 100 + } 101 + 95 102 static int mcs_touchkey_probe(struct i2c_client *client) 96 103 { 97 104 const struct i2c_device_id *id = i2c_client_get_device_id(client); ··· 116 109 return -EINVAL; 117 110 } 118 111 119 - data = kzalloc(struct_size(data, keycodes, pdata->key_maxval + 1), 120 - GFP_KERNEL); 121 - input_dev = input_allocate_device(); 122 - if (!data || !input_dev) { 123 - dev_err(&client->dev, "Failed to allocate memory\n"); 124 - error = -ENOMEM; 125 - goto err_free_mem; 112 + data = devm_kzalloc(&client->dev, 113 + struct_size(data, keycodes, pdata->key_maxval + 1), 114 + GFP_KERNEL); 115 + if (!data) 116 + return -ENOMEM; 117 + 118 + input_dev = devm_input_allocate_device(&client->dev); 119 + if (!input_dev) { 120 + dev_err(&client->dev, "Failed to allocate input device\n"); 121 + return -ENOMEM; 126 122 } 127 123 128 124 data->client = client; ··· 146 136 147 137 fw_ver = i2c_smbus_read_byte_data(client, fw_reg); 148 138 if (fw_ver < 0) { 149 - error = fw_ver; 150 - dev_err(&client->dev, "i2c read error[%d]\n", error); 151 - goto err_free_mem; 139 + dev_err(&client->dev, "i2c read error[%d]\n", fw_ver); 140 + return fw_ver; 152 141 } 153 142 dev_info(&client->dev, "Firmware version: %d\n", fw_ver); 154 143 155 144 input_dev->name = "MELFAS MCS Touchkey"; 156 145 input_dev->id.bustype = BUS_I2C; 157 - input_dev->dev.parent = &client->dev; 158 146 input_dev->evbit[0] = BIT_MASK(EV_KEY); 159 147 if (!pdata->no_autorepeat) 160 148 input_dev->evbit[0] |= BIT_MASK(EV_REP); ··· 177 169 if (pdata->poweron) { 178 170 data->poweron = pdata->poweron; 179 171 data->poweron(true); 172 + 173 + error = devm_add_action_or_reset(&client->dev, 174 + mcs_touchkey_poweroff, data); 175 + if (error) 176 + return error; 180 177 } 181 178 182 - error = request_threaded_irq(client->irq, NULL, mcs_touchkey_interrupt, 183 - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 184 - client->dev.driver->name, data); 179 + error = devm_request_threaded_irq(&client->dev, client->irq, 180 + NULL, mcs_touchkey_interrupt, 181 + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 182 + client->dev.driver->name, data); 185 183 if (error) { 186 184 dev_err(&client->dev, "Failed to register interrupt\n"); 187 - goto err_free_mem; 185 + return error; 188 186 } 189 187 190 188 error = input_register_device(input_dev); 191 189 if (error) 192 - goto err_free_irq; 190 + return error; 193 191 194 192 i2c_set_clientdata(client, data); 195 193 return 0; 196 - 197 - err_free_irq: 198 - free_irq(client->irq, data); 199 - err_free_mem: 200 - input_free_device(input_dev); 201 - kfree(data); 202 - return error; 203 - } 204 - 205 - static void mcs_touchkey_remove(struct i2c_client *client) 206 - { 207 - struct mcs_touchkey_data *data = i2c_get_clientdata(client); 208 - 209 - free_irq(client->irq, data); 210 - if (data->poweron) 211 - data->poweron(false); 212 - input_unregister_device(data->input_dev); 213 - kfree(data); 214 194 } 215 195 216 196 static void mcs_touchkey_shutdown(struct i2c_client *client) ··· 255 259 .pm = pm_sleep_ptr(&mcs_touchkey_pm_ops), 256 260 }, 257 261 .probe = mcs_touchkey_probe, 258 - .remove = mcs_touchkey_remove, 259 262 .shutdown = mcs_touchkey_shutdown, 260 263 .id_table = mcs_touchkey_id, 261 264 };
+35 -92
drivers/input/keyboard/nomadik-ske-keypad.c
··· 221 221 return IRQ_HANDLED; 222 222 } 223 223 224 + static void ske_keypad_board_exit(void *data) 225 + { 226 + struct ske_keypad *keypad = data; 227 + 228 + keypad->board->exit(); 229 + } 230 + 224 231 static int __init ske_keypad_probe(struct platform_device *pdev) 225 232 { 226 233 const struct ske_keypad_platform_data *plat = 227 234 dev_get_platdata(&pdev->dev); 235 + struct device *dev = &pdev->dev; 228 236 struct ske_keypad *keypad; 229 237 struct input_dev *input; 230 - struct resource *res; 231 238 int irq; 232 239 int error; 233 240 ··· 245 238 246 239 irq = platform_get_irq(pdev, 0); 247 240 if (irq < 0) 248 - return -EINVAL; 241 + return irq; 249 242 250 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 251 - if (!res) { 252 - dev_err(&pdev->dev, "missing platform resources\n"); 253 - return -EINVAL; 254 - } 255 - 256 - keypad = kzalloc(sizeof(struct ske_keypad), GFP_KERNEL); 257 - input = input_allocate_device(); 243 + keypad = devm_kzalloc(dev, sizeof(struct ske_keypad), 244 + GFP_KERNEL); 245 + input = devm_input_allocate_device(dev); 258 246 if (!keypad || !input) { 259 247 dev_err(&pdev->dev, "failed to allocate keypad memory\n"); 260 - error = -ENOMEM; 261 - goto err_free_mem; 248 + return -ENOMEM; 262 249 } 263 250 264 251 keypad->irq = irq; ··· 260 259 keypad->input = input; 261 260 spin_lock_init(&keypad->ske_keypad_lock); 262 261 263 - if (!request_mem_region(res->start, resource_size(res), pdev->name)) { 264 - dev_err(&pdev->dev, "failed to request I/O memory\n"); 265 - error = -EBUSY; 266 - goto err_free_mem; 267 - } 262 + keypad->reg_base = devm_platform_ioremap_resource(pdev, 0); 263 + if (IS_ERR(keypad->reg_base)) 264 + return PTR_ERR(keypad->reg_base); 268 265 269 - keypad->reg_base = ioremap(res->start, resource_size(res)); 270 - if (!keypad->reg_base) { 271 - dev_err(&pdev->dev, "failed to remap I/O memory\n"); 272 - error = -ENXIO; 273 - goto err_free_mem_region; 274 - } 275 - 276 - keypad->pclk = clk_get(&pdev->dev, "apb_pclk"); 266 + keypad->pclk = devm_clk_get_enabled(dev, "apb_pclk"); 277 267 if (IS_ERR(keypad->pclk)) { 278 268 dev_err(&pdev->dev, "failed to get pclk\n"); 279 - error = PTR_ERR(keypad->pclk); 280 - goto err_iounmap; 269 + return PTR_ERR(keypad->pclk); 281 270 } 282 271 283 - keypad->clk = clk_get(&pdev->dev, NULL); 272 + keypad->clk = devm_clk_get_enabled(dev, NULL); 284 273 if (IS_ERR(keypad->clk)) { 285 274 dev_err(&pdev->dev, "failed to get clk\n"); 286 - error = PTR_ERR(keypad->clk); 287 - goto err_pclk; 275 + return PTR_ERR(keypad->clk); 288 276 } 289 277 290 278 input->id.bustype = BUS_HOST; ··· 285 295 keypad->keymap, input); 286 296 if (error) { 287 297 dev_err(&pdev->dev, "Failed to build keymap\n"); 288 - goto err_clk; 298 + return error; 289 299 } 290 300 291 301 input_set_capability(input, EV_MSC, MSC_SCAN); 292 302 if (!plat->no_autorepeat) 293 303 __set_bit(EV_REP, input->evbit); 294 304 295 - error = clk_prepare_enable(keypad->pclk); 296 - if (error) { 297 - dev_err(&pdev->dev, "Failed to prepare/enable pclk\n"); 298 - goto err_clk; 299 - } 300 - 301 - error = clk_prepare_enable(keypad->clk); 302 - if (error) { 303 - dev_err(&pdev->dev, "Failed to prepare/enable clk\n"); 304 - goto err_pclk_disable; 305 - } 306 - 307 - 308 305 /* go through board initialization helpers */ 309 306 if (keypad->board->init) 310 307 keypad->board->init(); 311 308 309 + if (keypad->board->exit) { 310 + error = devm_add_action_or_reset(dev, ske_keypad_board_exit, 311 + keypad); 312 + if (error) 313 + return error; 314 + } 315 + 312 316 error = ske_keypad_chip_init(keypad); 313 317 if (error) { 314 318 dev_err(&pdev->dev, "unable to init keypad hardware\n"); 315 - goto err_clk_disable; 319 + return error; 316 320 } 317 321 318 - error = request_threaded_irq(keypad->irq, NULL, ske_keypad_irq, 319 - IRQF_ONESHOT, "ske-keypad", keypad); 322 + error = devm_request_threaded_irq(dev, keypad->irq, 323 + NULL, ske_keypad_irq, 324 + IRQF_ONESHOT, "ske-keypad", keypad); 320 325 if (error) { 321 326 dev_err(&pdev->dev, "allocate irq %d failed\n", keypad->irq); 322 - goto err_clk_disable; 327 + return error; 323 328 } 324 329 325 330 error = input_register_device(input); 326 331 if (error) { 327 332 dev_err(&pdev->dev, 328 - "unable to register input device: %d\n", error); 329 - goto err_free_irq; 333 + "unable to register input device: %d\n", error); 334 + return error; 330 335 } 331 336 332 337 if (plat->wakeup_enable) 333 338 device_init_wakeup(&pdev->dev, true); 334 339 335 340 platform_set_drvdata(pdev, keypad); 336 - 337 - return 0; 338 - 339 - err_free_irq: 340 - free_irq(keypad->irq, keypad); 341 - err_clk_disable: 342 - clk_disable_unprepare(keypad->clk); 343 - err_pclk_disable: 344 - clk_disable_unprepare(keypad->pclk); 345 - err_clk: 346 - clk_put(keypad->clk); 347 - err_pclk: 348 - clk_put(keypad->pclk); 349 - err_iounmap: 350 - iounmap(keypad->reg_base); 351 - err_free_mem_region: 352 - release_mem_region(res->start, resource_size(res)); 353 - err_free_mem: 354 - input_free_device(input); 355 - kfree(keypad); 356 - return error; 357 - } 358 - 359 - static int ske_keypad_remove(struct platform_device *pdev) 360 - { 361 - struct ske_keypad *keypad = platform_get_drvdata(pdev); 362 - struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 363 - 364 - free_irq(keypad->irq, keypad); 365 - 366 - input_unregister_device(keypad->input); 367 - 368 - clk_disable_unprepare(keypad->clk); 369 - clk_put(keypad->clk); 370 - 371 - if (keypad->board->exit) 372 - keypad->board->exit(); 373 - 374 - iounmap(keypad->reg_base); 375 - release_mem_region(res->start, resource_size(res)); 376 - kfree(keypad); 377 341 378 342 return 0; 379 343 } ··· 368 424 .name = "nmk-ske-keypad", 369 425 .pm = pm_sleep_ptr(&ske_keypad_dev_pm_ops), 370 426 }, 371 - .remove = ske_keypad_remove, 372 427 }; 373 428 374 429 module_platform_driver_probe(ske_keypad_driver, ske_keypad_probe);
+1 -2
drivers/input/keyboard/nspire-keypad.c
··· 186 186 return PTR_ERR(keypad->clk); 187 187 } 188 188 189 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 190 - keypad->reg_base = devm_ioremap_resource(&pdev->dev, res); 189 + keypad->reg_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 191 190 if (IS_ERR(keypad->reg_base)) 192 191 return PTR_ERR(keypad->reg_base); 193 192
+1 -8
drivers/input/keyboard/omap4-keypad.c
··· 341 341 struct device *dev = &pdev->dev; 342 342 struct omap4_keypad *keypad_data; 343 343 struct input_dev *input_dev; 344 - struct resource *res; 345 344 unsigned int max_keys; 346 345 int irq; 347 346 int error; 348 - 349 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 350 - if (!res) { 351 - dev_err(&pdev->dev, "no base address specified\n"); 352 - return -EINVAL; 353 - } 354 347 355 348 irq = platform_get_irq(pdev, 0); 356 349 if (irq < 0) ··· 363 370 if (error) 364 371 return error; 365 372 366 - keypad_data->base = devm_ioremap_resource(dev, res); 373 + keypad_data->base = devm_platform_ioremap_resource(pdev, 0); 367 374 if (IS_ERR(keypad_data->base)) 368 375 return PTR_ERR(keypad_data->base); 369 376
+1 -8
drivers/input/keyboard/opencores-kbd.c
··· 39 39 { 40 40 struct input_dev *input; 41 41 struct opencores_kbd *opencores_kbd; 42 - struct resource *res; 43 42 int irq, i, error; 44 - 45 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 46 - if (!res) { 47 - dev_err(&pdev->dev, "missing board memory resource\n"); 48 - return -EINVAL; 49 - } 50 43 51 44 irq = platform_get_irq(pdev, 0); 52 45 if (irq < 0) ··· 58 65 59 66 opencores_kbd->input = input; 60 67 61 - opencores_kbd->addr = devm_ioremap_resource(&pdev->dev, res); 68 + opencores_kbd->addr = devm_platform_ioremap_resource(pdev, 0); 62 69 if (IS_ERR(opencores_kbd->addr)) 63 70 return PTR_ERR(opencores_kbd->addr); 64 71
+1 -19
drivers/input/keyboard/pinephone-keyboard.c
··· 318 318 ppkb_set_scan(client, false); 319 319 } 320 320 321 - static void ppkb_regulator_disable(void *regulator) 322 - { 323 - regulator_disable(regulator); 324 - } 325 - 326 321 static int ppkb_probe(struct i2c_client *client) 327 322 { 328 323 struct device *dev = &client->dev; 329 324 unsigned int phys_rows, phys_cols; 330 325 struct pinephone_keyboard *ppkb; 331 - struct regulator *vbat_supply; 332 326 u8 info[PPKB_MATRIX_SIZE + 1]; 333 327 struct device_node *i2c_bus; 334 328 int ret; 335 329 int error; 336 330 337 - vbat_supply = devm_regulator_get(dev, "vbat"); 338 - error = PTR_ERR_OR_ZERO(vbat_supply); 331 + error = devm_regulator_get_enable(dev, "vbat"); 339 332 if (error) { 340 333 dev_err(dev, "Failed to get VBAT supply: %d\n", error); 341 334 return error; 342 335 } 343 - 344 - error = regulator_enable(vbat_supply); 345 - if (error) { 346 - dev_err(dev, "Failed to enable VBAT: %d\n", error); 347 - return error; 348 - } 349 - 350 - error = devm_add_action_or_reset(dev, ppkb_regulator_disable, 351 - vbat_supply); 352 - if (error) 353 - return error; 354 336 355 337 ret = i2c_smbus_read_i2c_block_data(client, 0, sizeof(info), info); 356 338 if (ret != sizeof(info)) {
+1 -8
drivers/input/keyboard/pxa27x_keypad.c
··· 717 717 struct device_node *np = pdev->dev.of_node; 718 718 struct pxa27x_keypad *keypad; 719 719 struct input_dev *input_dev; 720 - struct resource *res; 721 720 int irq, error; 722 721 723 722 /* Driver need build keycode from device tree or pdata */ ··· 726 727 irq = platform_get_irq(pdev, 0); 727 728 if (irq < 0) 728 729 return -ENXIO; 729 - 730 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 731 - if (res == NULL) { 732 - dev_err(&pdev->dev, "failed to get I/O memory\n"); 733 - return -ENXIO; 734 - } 735 730 736 731 keypad = devm_kzalloc(&pdev->dev, sizeof(*keypad), 737 732 GFP_KERNEL); ··· 740 747 keypad->input_dev = input_dev; 741 748 keypad->irq = irq; 742 749 743 - keypad->mmio_base = devm_ioremap_resource(&pdev->dev, res); 750 + keypad->mmio_base = devm_platform_ioremap_resource(pdev, 0); 744 751 if (IS_ERR(keypad->mmio_base)) 745 752 return PTR_ERR(keypad->mmio_base); 746 753
+14 -32
drivers/input/keyboard/qt1070.c
··· 149 149 if (!qt1070_identify(client)) 150 150 return -ENODEV; 151 151 152 - data = kzalloc(sizeof(struct qt1070_data), GFP_KERNEL); 153 - input = input_allocate_device(); 154 - if (!data || !input) { 155 - dev_err(&client->dev, "insufficient memory\n"); 156 - err = -ENOMEM; 157 - goto err_free_mem; 158 - } 152 + data = devm_kzalloc(&client->dev, sizeof(struct qt1070_data), 153 + GFP_KERNEL); 154 + if (!data) 155 + return -ENOMEM; 156 + 157 + input = devm_input_allocate_device(&client->dev); 158 + if (!input) 159 + return -ENOMEM; 159 160 160 161 data->client = client; 161 162 data->input = input; 162 163 data->irq = client->irq; 163 164 164 165 input->name = "AT42QT1070 QTouch Sensor"; 165 - input->dev.parent = &client->dev; 166 166 input->id.bustype = BUS_I2C; 167 167 168 168 /* Add the keycode */ ··· 185 185 qt1070_write(client, RESET, 1); 186 186 msleep(QT1070_RESET_TIME); 187 187 188 - err = request_threaded_irq(client->irq, NULL, qt1070_interrupt, 189 - IRQF_TRIGGER_NONE | IRQF_ONESHOT, 190 - client->dev.driver->name, data); 188 + err = devm_request_threaded_irq(&client->dev, client->irq, 189 + NULL, qt1070_interrupt, 190 + IRQF_TRIGGER_NONE | IRQF_ONESHOT, 191 + client->dev.driver->name, data); 191 192 if (err) { 192 193 dev_err(&client->dev, "fail to request irq\n"); 193 - goto err_free_mem; 194 + return err; 194 195 } 195 196 196 197 /* Register the input device */ 197 198 err = input_register_device(data->input); 198 199 if (err) { 199 200 dev_err(&client->dev, "Failed to register input device\n"); 200 - goto err_free_irq; 201 + return err; 201 202 } 202 203 203 204 i2c_set_clientdata(client, data); ··· 207 206 qt1070_read(client, DET_STATUS); 208 207 209 208 return 0; 210 - 211 - err_free_irq: 212 - free_irq(client->irq, data); 213 - err_free_mem: 214 - input_free_device(input); 215 - kfree(data); 216 - return err; 217 - } 218 - 219 - static void qt1070_remove(struct i2c_client *client) 220 - { 221 - struct qt1070_data *data = i2c_get_clientdata(client); 222 - 223 - /* Release IRQ */ 224 - free_irq(client->irq, data); 225 - 226 - input_unregister_device(data->input); 227 - kfree(data); 228 209 } 229 210 230 211 static int qt1070_suspend(struct device *dev) ··· 255 272 }, 256 273 .id_table = qt1070_id, 257 274 .probe = qt1070_probe, 258 - .remove = qt1070_remove, 259 275 }; 260 276 261 277 module_i2c_driver(qt1070_driver);
+37 -93
drivers/input/keyboard/qt2160.c
··· 32 32 33 33 #define QT2160_NUM_LEDS_X 8 34 34 35 - #define QT2160_CYCLE_INTERVAL (2*HZ) 35 + #define QT2160_CYCLE_INTERVAL 2000 /* msec - 2 sec */ 36 36 37 37 static unsigned char qt2160_key2code[] = { 38 38 KEY_0, KEY_1, KEY_2, KEY_3, ··· 54 54 struct qt2160_data { 55 55 struct i2c_client *client; 56 56 struct input_dev *input; 57 - struct delayed_work dwork; 58 57 unsigned short keycodes[ARRAY_SIZE(qt2160_key2code)]; 59 58 u16 key_matrix; 60 59 #ifdef CONFIG_LEDS_CLASS ··· 154 155 return 0; 155 156 } 156 157 157 - static int qt2160_get_key_matrix(struct qt2160_data *qt2160) 158 + static void qt2160_get_key_matrix(struct input_dev *input) 158 159 { 160 + struct qt2160_data *qt2160 = input_get_drvdata(input); 159 161 struct i2c_client *client = qt2160->client; 160 - struct input_dev *input = qt2160->input; 161 162 u8 regs[6]; 162 163 u16 old_matrix, new_matrix; 163 164 int ret, i, mask; ··· 172 173 if (ret) { 173 174 dev_err(&client->dev, 174 175 "could not perform chip read.\n"); 175 - return ret; 176 + return; 176 177 } 177 178 178 179 old_matrix = qt2160->key_matrix; ··· 190 191 } 191 192 192 193 input_sync(input); 193 - 194 - return 0; 195 194 } 196 195 197 - static irqreturn_t qt2160_irq(int irq, void *_qt2160) 196 + static irqreturn_t qt2160_irq(int irq, void *data) 198 197 { 199 - struct qt2160_data *qt2160 = _qt2160; 198 + struct input_dev *input = data; 200 199 201 - mod_delayed_work(system_wq, &qt2160->dwork, 0); 200 + qt2160_get_key_matrix(input); 202 201 203 202 return IRQ_HANDLED; 204 - } 205 - 206 - static void qt2160_schedule_read(struct qt2160_data *qt2160) 207 - { 208 - schedule_delayed_work(&qt2160->dwork, QT2160_CYCLE_INTERVAL); 209 - } 210 - 211 - static void qt2160_worker(struct work_struct *work) 212 - { 213 - struct qt2160_data *qt2160 = 214 - container_of(work, struct qt2160_data, dwork.work); 215 - 216 - dev_dbg(&qt2160->client->dev, "worker\n"); 217 - 218 - qt2160_get_key_matrix(qt2160); 219 - 220 - /* Avoid device lock up by checking every so often */ 221 - qt2160_schedule_read(qt2160); 222 203 } 223 204 224 205 static int qt2160_read(struct i2c_client *client, u8 reg) ··· 239 260 static int qt2160_register_leds(struct qt2160_data *qt2160) 240 261 { 241 262 struct i2c_client *client = qt2160->client; 242 - int ret; 263 + int error; 243 264 int i; 244 265 245 266 for (i = 0; i < QT2160_NUM_LEDS_X; i++) { ··· 252 273 led->id = i; 253 274 led->qt2160 = qt2160; 254 275 255 - ret = led_classdev_register(&client->dev, &led->cdev); 256 - if (ret < 0) 257 - return ret; 276 + error = devm_led_classdev_register(&client->dev, &led->cdev); 277 + if (error) 278 + return error; 258 279 } 259 280 260 281 /* Tur off LEDs */ ··· 265 286 return 0; 266 287 } 267 288 268 - static void qt2160_unregister_leds(struct qt2160_data *qt2160) 269 - { 270 - int i; 271 - 272 - for (i = 0; i < QT2160_NUM_LEDS_X; i++) 273 - led_classdev_unregister(&qt2160->leds[i].cdev); 274 - } 275 - 276 289 #else 277 290 278 291 static inline int qt2160_register_leds(struct qt2160_data *qt2160) 279 292 { 280 293 return 0; 281 - } 282 - 283 - static inline void qt2160_unregister_leds(struct qt2160_data *qt2160) 284 - { 285 294 } 286 295 287 296 #endif ··· 312 345 int i; 313 346 int error; 314 347 315 - /* Check functionality */ 316 - error = i2c_check_functionality(client->adapter, 317 - I2C_FUNC_SMBUS_BYTE); 318 - if (!error) { 348 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) { 319 349 dev_err(&client->dev, "%s adapter not supported\n", 320 - dev_driver_string(&client->adapter->dev)); 350 + dev_driver_string(&client->adapter->dev)); 321 351 return -ENODEV; 322 352 } 323 353 ··· 322 358 return -ENODEV; 323 359 324 360 /* Chip is valid and active. Allocate structure */ 325 - qt2160 = kzalloc(sizeof(struct qt2160_data), GFP_KERNEL); 326 - input = input_allocate_device(); 327 - if (!qt2160 || !input) { 328 - dev_err(&client->dev, "insufficient memory\n"); 329 - error = -ENOMEM; 330 - goto err_free_mem; 331 - } 361 + qt2160 = devm_kzalloc(&client->dev, sizeof(*qt2160), GFP_KERNEL); 362 + if (!qt2160) 363 + return -ENOMEM; 364 + 365 + input = devm_input_allocate_device(&client->dev); 366 + if (!input) 367 + return -ENOMEM; 332 368 333 369 qt2160->client = client; 334 370 qt2160->input = input; 335 - INIT_DELAYED_WORK(&qt2160->dwork, qt2160_worker); 336 371 337 372 input->name = "AT42QT2160 Touch Sense Keyboard"; 338 373 input->id.bustype = BUS_I2C; ··· 348 385 } 349 386 __clear_bit(KEY_RESERVED, input->keybit); 350 387 388 + input_set_drvdata(input, qt2160); 389 + 351 390 /* Calibrate device */ 352 391 error = qt2160_write(client, QT2160_CMD_CALIBRATE, 1); 353 392 if (error) { 354 393 dev_err(&client->dev, "failed to calibrate device\n"); 355 - goto err_free_mem; 394 + return error; 356 395 } 357 396 358 397 if (client->irq) { 359 - error = request_irq(client->irq, qt2160_irq, 360 - IRQF_TRIGGER_FALLING, "qt2160", qt2160); 398 + error = devm_request_threaded_irq(&client->dev, client->irq, 399 + NULL, qt2160_irq, 400 + IRQF_ONESHOT, 401 + "qt2160", input); 361 402 if (error) { 362 403 dev_err(&client->dev, 363 404 "failed to allocate irq %d\n", client->irq); 364 - goto err_free_mem; 405 + return error; 365 406 } 407 + } else { 408 + error = input_setup_polling(input, qt2160_get_key_matrix); 409 + if (error) { 410 + dev_err(&client->dev, "Failed to setup polling\n"); 411 + return error; 412 + } 413 + input_set_poll_interval(input, QT2160_CYCLE_INTERVAL); 366 414 } 367 415 368 416 error = qt2160_register_leds(qt2160); 369 417 if (error) { 370 418 dev_err(&client->dev, "Failed to register leds\n"); 371 - goto err_free_irq; 419 + return error; 372 420 } 373 421 374 422 error = input_register_device(qt2160->input); 375 423 if (error) { 376 424 dev_err(&client->dev, 377 425 "Failed to register input device\n"); 378 - goto err_unregister_leds; 426 + return error; 379 427 } 380 428 381 - i2c_set_clientdata(client, qt2160); 382 - qt2160_schedule_read(qt2160); 383 - 384 429 return 0; 385 - 386 - err_unregister_leds: 387 - qt2160_unregister_leds(qt2160); 388 - err_free_irq: 389 - if (client->irq) 390 - free_irq(client->irq, qt2160); 391 - err_free_mem: 392 - input_free_device(input); 393 - kfree(qt2160); 394 - return error; 395 - } 396 - 397 - static void qt2160_remove(struct i2c_client *client) 398 - { 399 - struct qt2160_data *qt2160 = i2c_get_clientdata(client); 400 - 401 - qt2160_unregister_leds(qt2160); 402 - 403 - /* Release IRQ so no queue will be scheduled */ 404 - if (client->irq) 405 - free_irq(client->irq, qt2160); 406 - 407 - cancel_delayed_work_sync(&qt2160->dwork); 408 - 409 - input_unregister_device(qt2160->input); 410 - kfree(qt2160); 411 430 } 412 431 413 432 static const struct i2c_device_id qt2160_idtable[] = { ··· 406 461 407 462 .id_table = qt2160_idtable, 408 463 .probe = qt2160_probe, 409 - .remove = qt2160_remove, 410 464 }; 411 465 412 466 module_i2c_driver(qt2160_driver);
+3 -3
drivers/input/keyboard/sun4i-lradc-keys.c
··· 21 21 #include <linux/interrupt.h> 22 22 #include <linux/io.h> 23 23 #include <linux/module.h> 24 - #include <linux/of_platform.h> 24 + #include <linux/of.h> 25 25 #include <linux/platform_device.h> 26 26 #include <linux/pm_wakeirq.h> 27 27 #include <linux/pm_wakeup.h> 28 + #include <linux/property.h> 28 29 #include <linux/regulator/consumer.h> 29 30 #include <linux/reset.h> 30 31 #include <linux/slab.h> ··· 308 307 309 308 input_set_drvdata(lradc->input, lradc); 310 309 311 - lradc->base = devm_ioremap_resource(dev, 312 - platform_get_resource(pdev, IORESOURCE_MEM, 0)); 310 + lradc->base = devm_platform_ioremap_resource(pdev, 0); 313 311 if (IS_ERR(lradc->base)) 314 312 return PTR_ERR(lradc->base); 315 313
+39 -100
drivers/input/keyboard/tca6416-keypad.c
··· 24 24 #define TCA6416_INVERT 2 25 25 #define TCA6416_DIRECTION 3 26 26 27 + #define TCA6416_POLL_INTERVAL 100 /* msec */ 28 + 27 29 static const struct i2c_device_id tca6416_id[] = { 28 30 { "tca6416-keys", 16, }, 29 31 { "tca6408-keys", 8, }, ··· 45 43 46 44 struct i2c_client *client; 47 45 struct input_dev *input; 48 - struct delayed_work dwork; 49 46 int io_size; 50 47 int irqnum; 51 48 u16 pinmask; ··· 86 85 return 0; 87 86 } 88 87 89 - static void tca6416_keys_scan(struct tca6416_keypad_chip *chip) 88 + static void tca6416_keys_scan(struct input_dev *input) 90 89 { 91 - struct input_dev *input = chip->input; 90 + struct tca6416_keypad_chip *chip = input_get_drvdata(input); 92 91 u16 reg_val, val; 93 92 int error, i, pin_index; 94 93 ··· 123 122 */ 124 123 static irqreturn_t tca6416_keys_isr(int irq, void *dev_id) 125 124 { 126 - struct tca6416_keypad_chip *chip = dev_id; 127 - 128 - tca6416_keys_scan(chip); 125 + tca6416_keys_scan(dev_id); 129 126 130 127 return IRQ_HANDLED; 131 - } 132 - 133 - static void tca6416_keys_work_func(struct work_struct *work) 134 - { 135 - struct tca6416_keypad_chip *chip = 136 - container_of(work, struct tca6416_keypad_chip, dwork.work); 137 - 138 - tca6416_keys_scan(chip); 139 - schedule_delayed_work(&chip->dwork, msecs_to_jiffies(100)); 140 128 } 141 129 142 130 static int tca6416_keys_open(struct input_dev *dev) 143 131 { 144 132 struct tca6416_keypad_chip *chip = input_get_drvdata(dev); 145 133 146 - /* Get initial device state in case it has switches */ 147 - tca6416_keys_scan(chip); 148 - 149 - if (chip->use_polling) 150 - schedule_delayed_work(&chip->dwork, msecs_to_jiffies(100)); 151 - else 152 - enable_irq(chip->irqnum); 134 + if (!chip->use_polling) { 135 + /* Get initial device state in case it has switches */ 136 + tca6416_keys_scan(dev); 137 + enable_irq(chip->client->irq); 138 + } 153 139 154 140 return 0; 155 141 } ··· 145 157 { 146 158 struct tca6416_keypad_chip *chip = input_get_drvdata(dev); 147 159 148 - if (chip->use_polling) 149 - cancel_delayed_work_sync(&chip->dwork); 150 - else 151 - disable_irq(chip->irqnum); 160 + if (!chip->use_polling) 161 + disable_irq(chip->client->irq); 152 162 } 153 163 154 164 static int tca6416_setup_registers(struct tca6416_keypad_chip *chip) ··· 202 216 return -EINVAL; 203 217 } 204 218 205 - chip = kzalloc(struct_size(chip, buttons, pdata->nbuttons), GFP_KERNEL); 206 - input = input_allocate_device(); 207 - if (!chip || !input) { 208 - error = -ENOMEM; 209 - goto fail1; 210 - } 219 + chip = devm_kzalloc(&client->dev, 220 + struct_size(chip, buttons, pdata->nbuttons), 221 + GFP_KERNEL); 222 + if (!chip) 223 + return -ENOMEM; 224 + 225 + input = devm_input_allocate_device(&client->dev); 226 + if (!input) 227 + return -ENOMEM; 211 228 212 229 chip->client = client; 213 230 chip->input = input; ··· 218 229 chip->pinmask = pdata->pinmask; 219 230 chip->use_polling = pdata->use_polling; 220 231 221 - INIT_DELAYED_WORK(&chip->dwork, tca6416_keys_work_func); 222 - 223 232 input->phys = "tca6416-keys/input0"; 224 233 input->name = client->name; 225 - input->dev.parent = &client->dev; 226 234 227 235 input->open = tca6416_keys_open; 228 236 input->close = tca6416_keys_close; ··· 249 263 */ 250 264 error = tca6416_setup_registers(chip); 251 265 if (error) 252 - goto fail1; 266 + return error; 253 267 254 - if (!chip->use_polling) { 255 - if (pdata->irq_is_gpio) 256 - chip->irqnum = gpio_to_irq(client->irq); 257 - else 258 - chip->irqnum = client->irq; 268 + if (chip->use_polling) { 269 + error = input_setup_polling(input, tca6416_keys_scan); 270 + if (error) { 271 + dev_err(&client->dev, "Failed to setup polling\n"); 272 + return error; 273 + } 259 274 260 - error = request_threaded_irq(chip->irqnum, NULL, 261 - tca6416_keys_isr, 262 - IRQF_TRIGGER_FALLING | 263 - IRQF_ONESHOT | IRQF_NO_AUTOEN, 264 - "tca6416-keypad", chip); 275 + input_set_poll_interval(input, TCA6416_POLL_INTERVAL); 276 + } else { 277 + error = devm_request_threaded_irq(&client->dev, client->irq, 278 + NULL, tca6416_keys_isr, 279 + IRQF_TRIGGER_FALLING | 280 + IRQF_ONESHOT | 281 + IRQF_NO_AUTOEN, 282 + "tca6416-keypad", input); 265 283 if (error) { 266 284 dev_dbg(&client->dev, 267 285 "Unable to claim irq %d; error %d\n", 268 - chip->irqnum, error); 269 - goto fail1; 286 + client->irq, error); 287 + return error; 270 288 } 271 289 } 272 290 ··· 278 288 if (error) { 279 289 dev_dbg(&client->dev, 280 290 "Unable to register input device, error: %d\n", error); 281 - goto fail2; 291 + return error; 282 292 } 283 293 284 294 i2c_set_clientdata(client, chip); 285 - device_init_wakeup(&client->dev, 1); 286 - 287 - return 0; 288 - 289 - fail2: 290 - if (!chip->use_polling) { 291 - free_irq(chip->irqnum, chip); 292 - enable_irq(chip->irqnum); 293 - } 294 - fail1: 295 - input_free_device(input); 296 - kfree(chip); 297 - return error; 298 - } 299 - 300 - static void tca6416_keypad_remove(struct i2c_client *client) 301 - { 302 - struct tca6416_keypad_chip *chip = i2c_get_clientdata(client); 303 - 304 - if (!chip->use_polling) { 305 - free_irq(chip->irqnum, chip); 306 - enable_irq(chip->irqnum); 307 - } 308 - 309 - input_unregister_device(chip->input); 310 - kfree(chip); 311 - } 312 - 313 - static int tca6416_keypad_suspend(struct device *dev) 314 - { 315 - struct i2c_client *client = to_i2c_client(dev); 316 - struct tca6416_keypad_chip *chip = i2c_get_clientdata(client); 317 - 318 - if (device_may_wakeup(dev)) 319 - enable_irq_wake(chip->irqnum); 320 295 321 296 return 0; 322 297 } 323 - 324 - static int tca6416_keypad_resume(struct device *dev) 325 - { 326 - struct i2c_client *client = to_i2c_client(dev); 327 - struct tca6416_keypad_chip *chip = i2c_get_clientdata(client); 328 - 329 - if (device_may_wakeup(dev)) 330 - disable_irq_wake(chip->irqnum); 331 - 332 - return 0; 333 - } 334 - 335 - static DEFINE_SIMPLE_DEV_PM_OPS(tca6416_keypad_dev_pm_ops, 336 - tca6416_keypad_suspend, tca6416_keypad_resume); 337 298 338 299 static struct i2c_driver tca6416_keypad_driver = { 339 300 .driver = { 340 301 .name = "tca6416-keypad", 341 - .pm = pm_sleep_ptr(&tca6416_keypad_dev_pm_ops), 342 302 }, 343 303 .probe = tca6416_keypad_probe, 344 - .remove = tca6416_keypad_remove, 345 304 .id_table = tca6416_id, 346 305 }; 347 306
+1 -1
drivers/input/keyboard/tegra-kbc.c
··· 640 640 641 641 timer_setup(&kbc->timer, tegra_kbc_keypress_timer, 0); 642 642 643 - kbc->mmio = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); 643 + kbc->mmio = devm_platform_ioremap_resource(pdev, 0); 644 644 if (IS_ERR(kbc->mmio)) 645 645 return PTR_ERR(kbc->mmio); 646 646
-1
drivers/input/keyboard/tm2-touchkey.c
··· 19 19 #include <linux/leds.h> 20 20 #include <linux/module.h> 21 21 #include <linux/of.h> 22 - #include <linux/of_device.h> 23 22 #include <linux/pm.h> 24 23 #include <linux/regulator/consumer.h> 25 24
+2 -2
drivers/input/misc/Kconfig
··· 791 791 module will be called iqs626a. 792 792 793 793 config INPUT_IQS7222 794 - tristate "Azoteq IQS7222A/B/C capacitive touch controller" 794 + tristate "Azoteq IQS7222A/B/C/D capacitive touch controller" 795 795 depends on I2C 796 796 help 797 - Say Y to enable support for the Azoteq IQS7222A/B/C family 797 + Say Y to enable support for the Azoteq IQS7222A/B/C/D family 798 798 of capacitive touch controllers. 799 799 800 800 To compile this driver as a module, choose M here: the
+2 -10
drivers/input/misc/cpcap-pwrbutton.c
··· 1 - /** 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 2 3 * CPCAP Power Button Input Driver 3 4 * 4 5 * Copyright (C) 2017 Sebastian Reichel <sre@kernel.org> 5 - * 6 - * This file is subject to the terms and conditions of the GNU General 7 - * Public License. See the file "COPYING" in the main directory of this 8 - * archive for more details. 9 - * 10 - * This program is distributed in the hope that it will be useful, 11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 - * GNU General Public License for more details. 14 6 */ 15 7 16 8 #include <linux/module.h>
+9
drivers/input/misc/da9063_onkey.c
··· 10 10 #include <linux/input.h> 11 11 #include <linux/interrupt.h> 12 12 #include <linux/platform_device.h> 13 + #include <linux/pm_wakeirq.h> 13 14 #include <linux/workqueue.h> 14 15 #include <linux/regmap.h> 15 16 #include <linux/of.h> ··· 251 250 "Failed to request IRQ %d: %d\n", irq, error); 252 251 return error; 253 252 } 253 + 254 + error = dev_pm_set_wake_irq(&pdev->dev, irq); 255 + if (error) 256 + dev_warn(&pdev->dev, 257 + "Failed to set IRQ %d as a wake IRQ: %d\n", 258 + irq, error); 259 + else 260 + device_init_wakeup(&pdev->dev, true); 254 261 255 262 error = input_register_device(onkey->input); 256 263 if (error) {
+7 -15
drivers/input/misc/gpio-vibra.c
··· 18 18 #include <linux/input.h> 19 19 #include <linux/kernel.h> 20 20 #include <linux/module.h> 21 - #include <linux/of_device.h> 21 + #include <linux/of.h> 22 22 #include <linux/platform_device.h> 23 23 #include <linux/property.h> 24 24 #include <linux/regulator/consumer.h> ··· 113 113 return -ENOMEM; 114 114 115 115 vibrator->vcc = devm_regulator_get(&pdev->dev, "vcc"); 116 - err = PTR_ERR_OR_ZERO(vibrator->vcc); 117 - if (err) { 118 - if (err != -EPROBE_DEFER) 119 - dev_err(&pdev->dev, "Failed to request regulator: %d\n", 120 - err); 121 - return err; 122 - } 116 + if (IS_ERR(vibrator->vcc)) 117 + return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->vcc), 118 + "Failed to request regulator\n"); 123 119 124 120 vibrator->gpio = devm_gpiod_get(&pdev->dev, "enable", GPIOD_OUT_LOW); 125 - err = PTR_ERR_OR_ZERO(vibrator->gpio); 126 - if (err) { 127 - if (err != -EPROBE_DEFER) 128 - dev_err(&pdev->dev, "Failed to request main gpio: %d\n", 129 - err); 130 - return err; 131 - } 121 + if (IS_ERR(vibrator->gpio)) 122 + return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->gpio), 123 + "Failed to request main gpio\n"); 132 124 133 125 INIT_WORK(&vibrator->play_work, gpio_vibrator_play_work); 134 126
+1 -1
drivers/input/misc/iqs269a.c
··· 17 17 #include <linux/input.h> 18 18 #include <linux/interrupt.h> 19 19 #include <linux/kernel.h> 20 + #include <linux/mod_devicetable.h> 20 21 #include <linux/module.h> 21 22 #include <linux/mutex.h> 22 - #include <linux/of_device.h> 23 23 #include <linux/property.h> 24 24 #include <linux/regmap.h> 25 25 #include <linux/slab.h>
+1 -1
drivers/input/misc/iqs626a.c
··· 19 19 #include <linux/input/touchscreen.h> 20 20 #include <linux/interrupt.h> 21 21 #include <linux/kernel.h> 22 + #include <linux/mod_devicetable.h> 22 23 #include <linux/module.h> 23 - #include <linux/of_device.h> 24 24 #include <linux/property.h> 25 25 #include <linux/regmap.h> 26 26 #include <linux/slab.h>
+464 -14
drivers/input/misc/iqs7222.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-or-later 2 2 /* 3 - * Azoteq IQS7222A/B/C Capacitive Touch Controller 3 + * Azoteq IQS7222A/B/C/D Capacitive Touch Controller 4 4 * 5 5 * Copyright (C) 2022 Jeff LaBundy <jeff@labundy.com> 6 6 */ ··· 12 12 #include <linux/gpio/consumer.h> 13 13 #include <linux/i2c.h> 14 14 #include <linux/input.h> 15 + #include <linux/input/touchscreen.h> 15 16 #include <linux/interrupt.h> 16 17 #include <linux/kernel.h> 17 18 #include <linux/ktime.h> 19 + #include <linux/mod_devicetable.h> 18 20 #include <linux/module.h> 19 - #include <linux/of_device.h> 20 21 #include <linux/property.h> 21 22 #include <linux/slab.h> 22 23 #include <asm/unaligned.h> ··· 26 25 #define IQS7222_PROD_NUM_A 840 27 26 #define IQS7222_PROD_NUM_B 698 28 27 #define IQS7222_PROD_NUM_C 863 28 + #define IQS7222_PROD_NUM_D 1046 29 29 30 30 #define IQS7222_SYS_STATUS 0x10 31 31 #define IQS7222_SYS_STATUS_RESET BIT(3) ··· 56 54 57 55 #define IQS7222_EVENT_MASK_ATI BIT(12) 58 56 #define IQS7222_EVENT_MASK_SLDR BIT(10) 57 + #define IQS7222_EVENT_MASK_TPAD IQS7222_EVENT_MASK_SLDR 59 58 #define IQS7222_EVENT_MASK_TOUCH BIT(1) 60 59 #define IQS7222_EVENT_MASK_PROX BIT(0) 61 60 ··· 74 71 #define IQS7222_MAX_COLS_CHAN 6 75 72 #define IQS7222_MAX_COLS_FILT 2 76 73 #define IQS7222_MAX_COLS_SLDR 11 74 + #define IQS7222_MAX_COLS_TPAD 24 77 75 #define IQS7222_MAX_COLS_GPIO 3 78 76 #define IQS7222_MAX_COLS_SYS 13 79 77 ··· 106 102 IQS7222_REG_GRP_BTN, 107 103 IQS7222_REG_GRP_CHAN, 108 104 IQS7222_REG_GRP_SLDR, 105 + IQS7222_REG_GRP_TPAD, 109 106 IQS7222_REG_GRP_GPIO, 110 107 IQS7222_REG_GRP_SYS, 111 108 IQS7222_NUM_REG_GRPS 112 109 }; 113 110 114 111 static const char * const iqs7222_reg_grp_names[IQS7222_NUM_REG_GRPS] = { 115 - [IQS7222_REG_GRP_CYCLE] = "cycle", 116 - [IQS7222_REG_GRP_CHAN] = "channel", 117 - [IQS7222_REG_GRP_SLDR] = "slider", 118 - [IQS7222_REG_GRP_GPIO] = "gpio", 112 + [IQS7222_REG_GRP_CYCLE] = "cycle-%d", 113 + [IQS7222_REG_GRP_CHAN] = "channel-%d", 114 + [IQS7222_REG_GRP_SLDR] = "slider-%d", 115 + [IQS7222_REG_GRP_TPAD] = "trackpad", 116 + [IQS7222_REG_GRP_GPIO] = "gpio-%d", 119 117 }; 120 118 121 119 static const unsigned int iqs7222_max_cols[IQS7222_NUM_REG_GRPS] = { ··· 128 122 [IQS7222_REG_GRP_CHAN] = IQS7222_MAX_COLS_CHAN, 129 123 [IQS7222_REG_GRP_FILT] = IQS7222_MAX_COLS_FILT, 130 124 [IQS7222_REG_GRP_SLDR] = IQS7222_MAX_COLS_SLDR, 125 + [IQS7222_REG_GRP_TPAD] = IQS7222_MAX_COLS_TPAD, 131 126 [IQS7222_REG_GRP_GPIO] = IQS7222_MAX_COLS_GPIO, 132 127 [IQS7222_REG_GRP_SYS] = IQS7222_MAX_COLS_SYS, 133 128 }; ··· 137 130 138 131 struct iqs7222_event_desc { 139 132 const char *name; 133 + u16 link; 140 134 u16 mask; 141 135 u16 val; 136 + u16 strict; 142 137 u16 enable; 143 138 enum iqs7222_reg_key_id reg_key; 144 139 }; ··· 192 183 .name = "event-flick-neg", 193 184 .mask = BIT(5) | BIT(2), 194 185 .val = BIT(5) | BIT(2), 186 + .enable = BIT(2), 187 + .reg_key = IQS7222_REG_KEY_AXIAL, 188 + }, 189 + }; 190 + 191 + static const struct iqs7222_event_desc iqs7222_tp_events[] = { 192 + { 193 + .name = "event-press", 194 + .link = BIT(7), 195 + }, 196 + { 197 + .name = "event-tap", 198 + .link = BIT(0), 199 + .mask = BIT(0), 200 + .val = BIT(0), 201 + .enable = BIT(0), 202 + .reg_key = IQS7222_REG_KEY_TAP, 203 + }, 204 + { 205 + .name = "event-swipe-x-pos", 206 + .link = BIT(2), 207 + .mask = BIT(2) | BIT(1), 208 + .val = BIT(2), 209 + .strict = BIT(4), 210 + .enable = BIT(1), 211 + .reg_key = IQS7222_REG_KEY_AXIAL, 212 + }, 213 + { 214 + .name = "event-swipe-y-pos", 215 + .link = BIT(3), 216 + .mask = BIT(3) | BIT(1), 217 + .val = BIT(3), 218 + .strict = BIT(3), 219 + .enable = BIT(1), 220 + .reg_key = IQS7222_REG_KEY_AXIAL, 221 + }, 222 + { 223 + .name = "event-swipe-x-neg", 224 + .link = BIT(4), 225 + .mask = BIT(4) | BIT(1), 226 + .val = BIT(4), 227 + .strict = BIT(4), 228 + .enable = BIT(1), 229 + .reg_key = IQS7222_REG_KEY_AXIAL, 230 + }, 231 + { 232 + .name = "event-swipe-y-neg", 233 + .link = BIT(5), 234 + .mask = BIT(5) | BIT(1), 235 + .val = BIT(5), 236 + .strict = BIT(3), 237 + .enable = BIT(1), 238 + .reg_key = IQS7222_REG_KEY_AXIAL, 239 + }, 240 + { 241 + .name = "event-flick-x-pos", 242 + .link = BIT(2), 243 + .mask = BIT(2) | BIT(1), 244 + .val = BIT(2) | BIT(1), 245 + .strict = BIT(4), 246 + .enable = BIT(2), 247 + .reg_key = IQS7222_REG_KEY_AXIAL, 248 + }, 249 + { 250 + .name = "event-flick-y-pos", 251 + .link = BIT(3), 252 + .mask = BIT(3) | BIT(1), 253 + .val = BIT(3) | BIT(1), 254 + .strict = BIT(3), 255 + .enable = BIT(2), 256 + .reg_key = IQS7222_REG_KEY_AXIAL, 257 + }, 258 + { 259 + .name = "event-flick-x-neg", 260 + .link = BIT(4), 261 + .mask = BIT(4) | BIT(1), 262 + .val = BIT(4) | BIT(1), 263 + .strict = BIT(4), 264 + .enable = BIT(2), 265 + .reg_key = IQS7222_REG_KEY_AXIAL, 266 + }, 267 + { 268 + .name = "event-flick-y-neg", 269 + .link = BIT(5), 270 + .mask = BIT(5) | BIT(1), 271 + .val = BIT(5) | BIT(1), 272 + .strict = BIT(3), 195 273 .enable = BIT(2), 196 274 .reg_key = IQS7222_REG_KEY_AXIAL, 197 275 }, ··· 617 521 .base = IQS7222_SYS_SETUP, 618 522 .num_row = 1, 619 523 .num_col = 11, 524 + }, 525 + }, 526 + }, 527 + { 528 + .prod_num = IQS7222_PROD_NUM_D, 529 + .fw_major = 0, 530 + .fw_minor = 37, 531 + .touch_link = 1770, 532 + .allow_offset = 9, 533 + .event_offset = 10, 534 + .comms_offset = 11, 535 + .reg_grps = { 536 + [IQS7222_REG_GRP_STAT] = { 537 + .base = IQS7222_SYS_STATUS, 538 + .num_row = 1, 539 + .num_col = 7, 540 + }, 541 + [IQS7222_REG_GRP_CYCLE] = { 542 + .base = 0x8000, 543 + .num_row = 7, 544 + .num_col = 2, 545 + }, 546 + [IQS7222_REG_GRP_GLBL] = { 547 + .base = 0x8700, 548 + .num_row = 1, 549 + .num_col = 3, 550 + }, 551 + [IQS7222_REG_GRP_BTN] = { 552 + .base = 0x9000, 553 + .num_row = 14, 554 + .num_col = 3, 555 + }, 556 + [IQS7222_REG_GRP_CHAN] = { 557 + .base = 0xA000, 558 + .num_row = 14, 559 + .num_col = 4, 560 + }, 561 + [IQS7222_REG_GRP_FILT] = { 562 + .base = 0xAE00, 563 + .num_row = 1, 564 + .num_col = 2, 565 + }, 566 + [IQS7222_REG_GRP_TPAD] = { 567 + .base = 0xB000, 568 + .num_row = 1, 569 + .num_col = 24, 570 + }, 571 + [IQS7222_REG_GRP_GPIO] = { 572 + .base = 0xC000, 573 + .num_row = 3, 574 + .num_col = 3, 575 + }, 576 + [IQS7222_REG_GRP_SYS] = { 577 + .base = IQS7222_SYS_SETUP, 578 + .num_row = 1, 579 + .num_col = 12, 620 580 }, 621 581 }, 622 582 }, ··· 1161 1009 .label = "maximum gesture time", 1162 1010 }, 1163 1011 { 1012 + .name = "azoteq,num-rows", 1013 + .reg_grp = IQS7222_REG_GRP_TPAD, 1014 + .reg_offset = 0, 1015 + .reg_shift = 4, 1016 + .reg_width = 4, 1017 + .val_min = 1, 1018 + .val_max = 12, 1019 + .label = "number of rows", 1020 + }, 1021 + { 1022 + .name = "azoteq,num-cols", 1023 + .reg_grp = IQS7222_REG_GRP_TPAD, 1024 + .reg_offset = 0, 1025 + .reg_shift = 0, 1026 + .reg_width = 4, 1027 + .val_min = 1, 1028 + .val_max = 12, 1029 + .label = "number of columns", 1030 + }, 1031 + { 1032 + .name = "azoteq,lower-cal-y", 1033 + .reg_grp = IQS7222_REG_GRP_TPAD, 1034 + .reg_offset = 1, 1035 + .reg_shift = 8, 1036 + .reg_width = 8, 1037 + .label = "lower vertical calibration", 1038 + }, 1039 + { 1040 + .name = "azoteq,lower-cal-x", 1041 + .reg_grp = IQS7222_REG_GRP_TPAD, 1042 + .reg_offset = 1, 1043 + .reg_shift = 0, 1044 + .reg_width = 8, 1045 + .label = "lower horizontal calibration", 1046 + }, 1047 + { 1048 + .name = "azoteq,upper-cal-y", 1049 + .reg_grp = IQS7222_REG_GRP_TPAD, 1050 + .reg_offset = 2, 1051 + .reg_shift = 8, 1052 + .reg_width = 8, 1053 + .label = "upper vertical calibration", 1054 + }, 1055 + { 1056 + .name = "azoteq,upper-cal-x", 1057 + .reg_grp = IQS7222_REG_GRP_TPAD, 1058 + .reg_offset = 2, 1059 + .reg_shift = 0, 1060 + .reg_width = 8, 1061 + .label = "upper horizontal calibration", 1062 + }, 1063 + { 1064 + .name = "azoteq,top-speed", 1065 + .reg_grp = IQS7222_REG_GRP_TPAD, 1066 + .reg_offset = 3, 1067 + .reg_shift = 8, 1068 + .reg_width = 8, 1069 + .val_pitch = 4, 1070 + .label = "top speed", 1071 + }, 1072 + { 1073 + .name = "azoteq,bottom-speed", 1074 + .reg_grp = IQS7222_REG_GRP_TPAD, 1075 + .reg_offset = 3, 1076 + .reg_shift = 0, 1077 + .reg_width = 8, 1078 + .label = "bottom speed", 1079 + }, 1080 + { 1081 + .name = "azoteq,gesture-min-ms", 1082 + .reg_grp = IQS7222_REG_GRP_TPAD, 1083 + .reg_key = IQS7222_REG_KEY_TAP, 1084 + .reg_offset = 20, 1085 + .reg_shift = 8, 1086 + .reg_width = 8, 1087 + .val_pitch = 16, 1088 + .label = "minimum gesture time", 1089 + }, 1090 + { 1091 + .name = "azoteq,gesture-max-ms", 1092 + .reg_grp = IQS7222_REG_GRP_TPAD, 1093 + .reg_key = IQS7222_REG_KEY_AXIAL, 1094 + .reg_offset = 21, 1095 + .reg_shift = 8, 1096 + .reg_width = 8, 1097 + .val_pitch = 16, 1098 + .label = "maximum gesture time", 1099 + }, 1100 + { 1101 + .name = "azoteq,gesture-max-ms", 1102 + .reg_grp = IQS7222_REG_GRP_TPAD, 1103 + .reg_key = IQS7222_REG_KEY_TAP, 1104 + .reg_offset = 21, 1105 + .reg_shift = 0, 1106 + .reg_width = 8, 1107 + .val_pitch = 16, 1108 + .label = "maximum gesture time", 1109 + }, 1110 + { 1111 + .name = "azoteq,gesture-dist", 1112 + .reg_grp = IQS7222_REG_GRP_TPAD, 1113 + .reg_key = IQS7222_REG_KEY_TAP, 1114 + .reg_offset = 22, 1115 + .reg_shift = 0, 1116 + .reg_width = 16, 1117 + .label = "gesture distance", 1118 + }, 1119 + { 1120 + .name = "azoteq,gesture-dist", 1121 + .reg_grp = IQS7222_REG_GRP_TPAD, 1122 + .reg_key = IQS7222_REG_KEY_AXIAL, 1123 + .reg_offset = 23, 1124 + .reg_shift = 0, 1125 + .reg_width = 16, 1126 + .label = "gesture distance", 1127 + }, 1128 + { 1164 1129 .name = "drive-open-drain", 1165 1130 .reg_grp = IQS7222_REG_GRP_GPIO, 1166 1131 .reg_offset = 0, ··· 1360 1091 struct gpio_desc *irq_gpio; 1361 1092 struct i2c_client *client; 1362 1093 struct input_dev *keypad; 1094 + struct touchscreen_properties prop; 1363 1095 unsigned int kp_type[IQS7222_MAX_CHAN][ARRAY_SIZE(iqs7222_kp_events)]; 1364 1096 unsigned int kp_code[IQS7222_MAX_CHAN][ARRAY_SIZE(iqs7222_kp_events)]; 1365 1097 unsigned int sl_code[IQS7222_MAX_SLDR][ARRAY_SIZE(iqs7222_sl_events)]; 1366 1098 unsigned int sl_axis[IQS7222_MAX_SLDR]; 1099 + unsigned int tp_code[ARRAY_SIZE(iqs7222_tp_events)]; 1367 1100 u16 cycle_setup[IQS7222_MAX_CHAN / 2][IQS7222_MAX_COLS_CYCLE]; 1368 1101 u16 glbl_setup[IQS7222_MAX_COLS_GLBL]; 1369 1102 u16 btn_setup[IQS7222_MAX_CHAN][IQS7222_MAX_COLS_BTN]; 1370 1103 u16 chan_setup[IQS7222_MAX_CHAN][IQS7222_MAX_COLS_CHAN]; 1371 1104 u16 filt_setup[IQS7222_MAX_COLS_FILT]; 1372 1105 u16 sldr_setup[IQS7222_MAX_SLDR][IQS7222_MAX_COLS_SLDR]; 1106 + u16 tpad_setup[IQS7222_MAX_COLS_TPAD]; 1373 1107 u16 gpio_setup[ARRAY_SIZE(iqs7222_gpio_links)][IQS7222_MAX_COLS_GPIO]; 1374 1108 u16 sys_setup[IQS7222_MAX_COLS_SYS]; 1375 1109 }; ··· 1398 1126 1399 1127 case IQS7222_REG_GRP_SLDR: 1400 1128 return iqs7222->sldr_setup[row]; 1129 + 1130 + case IQS7222_REG_GRP_TPAD: 1131 + return iqs7222->tpad_setup; 1401 1132 1402 1133 case IQS7222_REG_GRP_GPIO: 1403 1134 return iqs7222->gpio_setup[row]; ··· 1656 1381 if (error) 1657 1382 return error; 1658 1383 1659 - sys_setup &= ~IQS7222_SYS_SETUP_INTF_MODE_MASK; 1660 - sys_setup &= ~IQS7222_SYS_SETUP_PWR_MODE_MASK; 1661 - 1662 1384 for (i = 0; i < IQS7222_NUM_RETRIES; i++) { 1663 1385 /* 1664 1386 * Trigger ATI from streaming and normal-power modes so that ··· 1833 1561 return error; 1834 1562 } 1835 1563 1836 - if (dir == READ) 1564 + if (dir == READ) { 1565 + iqs7222->sys_setup[0] &= ~IQS7222_SYS_SETUP_INTF_MODE_MASK; 1566 + iqs7222->sys_setup[0] &= ~IQS7222_SYS_SETUP_PWR_MODE_MASK; 1837 1567 return 0; 1568 + } 1838 1569 1839 1570 return iqs7222_ati_trigger(iqs7222); 1840 1571 } ··· 2211 1936 ref_setup[4] = dev_desc->touch_link; 2212 1937 if (fwnode_property_present(chan_node, "azoteq,use-prox")) 2213 1938 ref_setup[4] -= 2; 1939 + } else if (dev_desc->reg_grps[IQS7222_REG_GRP_TPAD].num_row && 1940 + fwnode_property_present(chan_node, 1941 + "azoteq,counts-filt-enable")) { 1942 + /* 1943 + * In the case of IQS7222D, however, the reference mode field 1944 + * is partially repurposed as a counts filter enable control. 1945 + */ 1946 + chan_setup[0] |= IQS7222_CHAN_SETUP_0_REF_MODE_REF; 2214 1947 } 2215 1948 2216 1949 if (fwnode_property_present(chan_node, "azoteq,rx-enable")) { ··· 2561 2278 IQS7222_REG_KEY_NO_WHEEL); 2562 2279 } 2563 2280 2281 + static int iqs7222_parse_tpad(struct iqs7222_private *iqs7222, 2282 + struct fwnode_handle *tpad_node, int tpad_index) 2283 + { 2284 + const struct iqs7222_dev_desc *dev_desc = iqs7222->dev_desc; 2285 + struct touchscreen_properties *prop = &iqs7222->prop; 2286 + struct i2c_client *client = iqs7222->client; 2287 + int num_chan = dev_desc->reg_grps[IQS7222_REG_GRP_CHAN].num_row; 2288 + int count, error, i; 2289 + u16 *event_mask = &iqs7222->sys_setup[dev_desc->event_offset]; 2290 + u16 *tpad_setup = iqs7222->tpad_setup; 2291 + unsigned int chan_sel[12]; 2292 + 2293 + error = iqs7222_parse_props(iqs7222, tpad_node, tpad_index, 2294 + IQS7222_REG_GRP_TPAD, 2295 + IQS7222_REG_KEY_NONE); 2296 + if (error) 2297 + return error; 2298 + 2299 + count = fwnode_property_count_u32(tpad_node, "azoteq,channel-select"); 2300 + if (count < 0) { 2301 + dev_err(&client->dev, "Failed to count %s channels: %d\n", 2302 + fwnode_get_name(tpad_node), count); 2303 + return count; 2304 + } else if (!count || count > ARRAY_SIZE(chan_sel)) { 2305 + dev_err(&client->dev, "Invalid number of %s channels\n", 2306 + fwnode_get_name(tpad_node)); 2307 + return -EINVAL; 2308 + } 2309 + 2310 + error = fwnode_property_read_u32_array(tpad_node, 2311 + "azoteq,channel-select", 2312 + chan_sel, count); 2313 + if (error) { 2314 + dev_err(&client->dev, "Failed to read %s channels: %d\n", 2315 + fwnode_get_name(tpad_node), error); 2316 + return error; 2317 + } 2318 + 2319 + tpad_setup[6] &= ~GENMASK(num_chan - 1, 0); 2320 + 2321 + for (i = 0; i < ARRAY_SIZE(chan_sel); i++) { 2322 + tpad_setup[8 + i] = 0; 2323 + if (i >= count || chan_sel[i] == U8_MAX) 2324 + continue; 2325 + 2326 + if (chan_sel[i] >= num_chan) { 2327 + dev_err(&client->dev, "Invalid %s channel: %u\n", 2328 + fwnode_get_name(tpad_node), chan_sel[i]); 2329 + return -EINVAL; 2330 + } 2331 + 2332 + /* 2333 + * The following fields indicate which channels participate in 2334 + * the trackpad, as well as each channel's relative placement. 2335 + */ 2336 + tpad_setup[6] |= BIT(chan_sel[i]); 2337 + tpad_setup[8 + i] = chan_sel[i] * 34 + 1072; 2338 + } 2339 + 2340 + tpad_setup[7] = dev_desc->touch_link; 2341 + if (fwnode_property_present(tpad_node, "azoteq,use-prox")) 2342 + tpad_setup[7] -= 2; 2343 + 2344 + for (i = 0; i < ARRAY_SIZE(iqs7222_tp_events); i++) 2345 + tpad_setup[20] &= ~(iqs7222_tp_events[i].strict | 2346 + iqs7222_tp_events[i].enable); 2347 + 2348 + for (i = 0; i < ARRAY_SIZE(iqs7222_tp_events); i++) { 2349 + const char *event_name = iqs7222_tp_events[i].name; 2350 + struct fwnode_handle *event_node; 2351 + 2352 + event_node = fwnode_get_named_child_node(tpad_node, event_name); 2353 + if (!event_node) 2354 + continue; 2355 + 2356 + if (fwnode_property_present(event_node, 2357 + "azoteq,gesture-angle-tighten")) 2358 + tpad_setup[20] |= iqs7222_tp_events[i].strict; 2359 + 2360 + tpad_setup[20] |= iqs7222_tp_events[i].enable; 2361 + 2362 + error = iqs7222_parse_event(iqs7222, event_node, tpad_index, 2363 + IQS7222_REG_GRP_TPAD, 2364 + iqs7222_tp_events[i].reg_key, 2365 + iqs7222_tp_events[i].link, 1566, 2366 + NULL, 2367 + &iqs7222->tp_code[i]); 2368 + fwnode_handle_put(event_node); 2369 + if (error) 2370 + return error; 2371 + 2372 + if (!dev_desc->event_offset) 2373 + continue; 2374 + 2375 + /* 2376 + * The press/release event is determined based on whether the 2377 + * coordinate fields report 0xFFFF and solely relies on touch 2378 + * or proximity interrupts to be unmasked. 2379 + */ 2380 + if (i) 2381 + *event_mask |= IQS7222_EVENT_MASK_TPAD; 2382 + else if (tpad_setup[7] == dev_desc->touch_link) 2383 + *event_mask |= IQS7222_EVENT_MASK_TOUCH; 2384 + else 2385 + *event_mask |= IQS7222_EVENT_MASK_PROX; 2386 + } 2387 + 2388 + if (!iqs7222->tp_code[0]) 2389 + return 0; 2390 + 2391 + input_set_abs_params(iqs7222->keypad, ABS_X, 2392 + 0, (tpad_setup[4] ? : 1) - 1, 0, 0); 2393 + 2394 + input_set_abs_params(iqs7222->keypad, ABS_Y, 2395 + 0, (tpad_setup[5] ? : 1) - 1, 0, 0); 2396 + 2397 + touchscreen_parse_properties(iqs7222->keypad, false, prop); 2398 + 2399 + if (prop->max_x >= U16_MAX || prop->max_y >= U16_MAX) { 2400 + dev_err(&client->dev, "Invalid trackpad size: %u*%u\n", 2401 + prop->max_x, prop->max_y); 2402 + return -EINVAL; 2403 + } 2404 + 2405 + tpad_setup[4] = prop->max_x + 1; 2406 + tpad_setup[5] = prop->max_y + 1; 2407 + 2408 + return 0; 2409 + } 2410 + 2564 2411 static int (*iqs7222_parse_extra[IQS7222_NUM_REG_GRPS]) 2565 2412 (struct iqs7222_private *iqs7222, 2566 2413 struct fwnode_handle *reg_grp_node, ··· 2698 2285 [IQS7222_REG_GRP_CYCLE] = iqs7222_parse_cycle, 2699 2286 [IQS7222_REG_GRP_CHAN] = iqs7222_parse_chan, 2700 2287 [IQS7222_REG_GRP_SLDR] = iqs7222_parse_sldr, 2288 + [IQS7222_REG_GRP_TPAD] = iqs7222_parse_tpad, 2701 2289 }; 2702 2290 2703 2291 static int iqs7222_parse_reg_grp(struct iqs7222_private *iqs7222, ··· 2712 2298 if (iqs7222_reg_grp_names[reg_grp]) { 2713 2299 char reg_grp_name[16]; 2714 2300 2715 - snprintf(reg_grp_name, sizeof(reg_grp_name), "%s-%d", 2301 + snprintf(reg_grp_name, sizeof(reg_grp_name), 2716 2302 iqs7222_reg_grp_names[reg_grp], reg_grp_index); 2717 2303 2718 2304 reg_grp_node = device_get_named_child_node(&client->dev, ··· 2760 2346 continue; 2761 2347 2762 2348 /* 2763 - * The IQS7222C exposes multiple GPIO and must be informed 2764 - * as to which GPIO this group represents. 2349 + * The IQS7222C and IQS7222D expose multiple GPIO and must be 2350 + * informed as to which GPIO this group represents. 2765 2351 */ 2766 2352 for (j = 0; j < ARRAY_SIZE(iqs7222_gpio_links); j++) 2767 2353 gpio_setup[0] &= ~BIT(iqs7222_gpio_links[j]); ··· 2894 2480 iqs7222->sl_code[i][j], 0); 2895 2481 } 2896 2482 2483 + for (i = 0; i < dev_desc->reg_grps[IQS7222_REG_GRP_TPAD].num_row; i++) { 2484 + u16 tpad_pos_x = le16_to_cpu(status[4]); 2485 + u16 tpad_pos_y = le16_to_cpu(status[5]); 2486 + u16 state = le16_to_cpu(status[6]); 2487 + 2488 + input_report_key(iqs7222->keypad, iqs7222->tp_code[0], 2489 + tpad_pos_x < U16_MAX); 2490 + 2491 + if (tpad_pos_x < U16_MAX) 2492 + touchscreen_report_pos(iqs7222->keypad, &iqs7222->prop, 2493 + tpad_pos_x, tpad_pos_y, false); 2494 + 2495 + if (!(le16_to_cpu(status[1]) & IQS7222_EVENT_MASK_TPAD)) 2496 + continue; 2497 + 2498 + /* 2499 + * Skip the press/release event, as it does not have separate 2500 + * status fields and is handled separately. 2501 + */ 2502 + for (j = 1; j < ARRAY_SIZE(iqs7222_tp_events); j++) { 2503 + u16 mask = iqs7222_tp_events[j].mask; 2504 + u16 val = iqs7222_tp_events[j].val; 2505 + 2506 + input_report_key(iqs7222->keypad, 2507 + iqs7222->tp_code[j], 2508 + (state & mask) == val); 2509 + } 2510 + 2511 + input_sync(iqs7222->keypad); 2512 + 2513 + for (j = 1; j < ARRAY_SIZE(iqs7222_tp_events); j++) 2514 + input_report_key(iqs7222->keypad, 2515 + iqs7222->tp_code[j], 0); 2516 + } 2517 + 2897 2518 input_sync(iqs7222->keypad); 2898 2519 2899 2520 return 0; ··· 3033 2584 { .compatible = "azoteq,iqs7222a" }, 3034 2585 { .compatible = "azoteq,iqs7222b" }, 3035 2586 { .compatible = "azoteq,iqs7222c" }, 2587 + { .compatible = "azoteq,iqs7222d" }, 3036 2588 { } 3037 2589 }; 3038 2590 MODULE_DEVICE_TABLE(of, iqs7222_of_match); ··· 3048 2598 module_i2c_driver(iqs7222_i2c_driver); 3049 2599 3050 2600 MODULE_AUTHOR("Jeff LaBundy <jeff@labundy.com>"); 3051 - MODULE_DESCRIPTION("Azoteq IQS7222A/B/C Capacitive Touch Controller"); 2601 + MODULE_DESCRIPTION("Azoteq IQS7222A/B/C/D Capacitive Touch Controller"); 3052 2602 MODULE_LICENSE("GPL");
+1 -1
drivers/input/misc/mma8450.c
··· 11 11 #include <linux/delay.h> 12 12 #include <linux/i2c.h> 13 13 #include <linux/input.h> 14 - #include <linux/of_device.h> 14 + #include <linux/mod_devicetable.h> 15 15 16 16 #define MMA8450_DRV_NAME "mma8450" 17 17
-1
drivers/input/misc/pm8941-pwrkey.c
··· 14 14 #include <linux/module.h> 15 15 #include <linux/of.h> 16 16 #include <linux/of_address.h> 17 - #include <linux/of_device.h> 18 17 #include <linux/platform_device.h> 19 18 #include <linux/reboot.h> 20 19 #include <linux/regmap.h>
-1
drivers/input/misc/pm8xxx-vibrator.c
··· 7 7 #include <linux/kernel.h> 8 8 #include <linux/module.h> 9 9 #include <linux/of.h> 10 - #include <linux/of_device.h> 11 10 #include <linux/platform_device.h> 12 11 #include <linux/regmap.h> 13 12 #include <linux/slab.h>
-1
drivers/input/misc/pmic8xxx-pwrkey.c
··· 12 12 #include <linux/regmap.h> 13 13 #include <linux/log2.h> 14 14 #include <linux/of.h> 15 - #include <linux/of_device.h> 16 15 17 16 #define PON_CNTL_1 0x1C 18 17 #define PON_CNTL_PULL_UP BIT(7)
+5 -14
drivers/input/misc/pwm-beeper.c
··· 132 132 return -ENOMEM; 133 133 134 134 beeper->pwm = devm_pwm_get(dev, NULL); 135 - if (IS_ERR(beeper->pwm)) { 136 - error = PTR_ERR(beeper->pwm); 137 - if (error != -EPROBE_DEFER) 138 - dev_err(dev, "Failed to request PWM device: %d\n", 139 - error); 140 - return error; 141 - } 135 + if (IS_ERR(beeper->pwm)) 136 + return dev_err_probe(dev, PTR_ERR(beeper->pwm), "Failed to request PWM device\n"); 142 137 143 138 /* Sync up PWM state and ensure it is off. */ 144 139 pwm_init_state(beeper->pwm, &state); ··· 146 151 } 147 152 148 153 beeper->amplifier = devm_regulator_get(dev, "amp"); 149 - if (IS_ERR(beeper->amplifier)) { 150 - error = PTR_ERR(beeper->amplifier); 151 - if (error != -EPROBE_DEFER) 152 - dev_err(dev, "Failed to get 'amp' regulator: %d\n", 153 - error); 154 - return error; 155 - } 154 + if (IS_ERR(beeper->amplifier)) 155 + return dev_err_probe(dev, PTR_ERR(beeper->amplifier), 156 + "Failed to get 'amp' regulator\n"); 156 157 157 158 INIT_WORK(&beeper->work, pwm_beeper_work); 158 159
+10 -22
drivers/input/misc/pwm-vibra.c
··· 15 15 #include <linux/input.h> 16 16 #include <linux/kernel.h> 17 17 #include <linux/module.h> 18 - #include <linux/of_device.h> 18 + #include <linux/of.h> 19 19 #include <linux/platform_device.h> 20 20 #include <linux/property.h> 21 21 #include <linux/pwm.h> ··· 140 140 return -ENOMEM; 141 141 142 142 vibrator->vcc = devm_regulator_get(&pdev->dev, "vcc"); 143 - err = PTR_ERR_OR_ZERO(vibrator->vcc); 144 - if (err) { 145 - if (err != -EPROBE_DEFER) 146 - dev_err(&pdev->dev, "Failed to request regulator: %d\n", 147 - err); 148 - return err; 149 - } 143 + if (IS_ERR(vibrator->vcc)) 144 + return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->vcc), 145 + "Failed to request regulator\n"); 150 146 151 147 vibrator->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable", 152 148 GPIOD_OUT_LOW); 153 - err = PTR_ERR_OR_ZERO(vibrator->enable_gpio); 154 - if (err) { 155 - if (err != -EPROBE_DEFER) 156 - dev_err(&pdev->dev, "Failed to request enable gpio: %d\n", 157 - err); 158 - return err; 159 - } 149 + if (IS_ERR(vibrator->enable_gpio)) 150 + return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->enable_gpio), 151 + "Failed to request enable gpio\n"); 160 152 161 153 vibrator->pwm = devm_pwm_get(&pdev->dev, "enable"); 162 - err = PTR_ERR_OR_ZERO(vibrator->pwm); 163 - if (err) { 164 - if (err != -EPROBE_DEFER) 165 - dev_err(&pdev->dev, "Failed to request main pwm: %d\n", 166 - err); 167 - return err; 168 - } 154 + if (IS_ERR(vibrator->pwm)) 155 + return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->pwm), 156 + "Failed to request main pwm\n"); 169 157 170 158 INIT_WORK(&vibrator->play_work, pwm_vibrator_play_work); 171 159
+2 -7
drivers/input/misc/rotary_encoder.c
··· 236 236 device_property_read_bool(dev, "rotary-encoder,relative-axis"); 237 237 238 238 encoder->gpios = devm_gpiod_get_array(dev, NULL, GPIOD_IN); 239 - if (IS_ERR(encoder->gpios)) { 240 - err = PTR_ERR(encoder->gpios); 241 - if (err != -EPROBE_DEFER) 242 - dev_err(dev, "unable to get gpios: %d\n", err); 243 - return err; 244 - } 239 + if (IS_ERR(encoder->gpios)) 240 + return dev_err_probe(dev, PTR_ERR(encoder->gpios), "unable to get gpios\n"); 245 241 if (encoder->gpios->ndescs < 2) { 246 242 dev_err(dev, "not enough gpios found\n"); 247 243 return -EINVAL; ··· 251 255 252 256 input->name = pdev->name; 253 257 input->id.bustype = BUS_HOST; 254 - input->dev.parent = dev; 255 258 256 259 if (encoder->relative_axis) 257 260 input_set_capability(input, EV_REL, encoder->axis);
+2 -1
drivers/input/misc/sparcspkr.c
··· 9 9 #include <linux/module.h> 10 10 #include <linux/init.h> 11 11 #include <linux/input.h> 12 - #include <linux/of_device.h> 12 + #include <linux/of.h> 13 + #include <linux/platform_device.h> 13 14 #include <linux/slab.h> 14 15 15 16 #include <asm/io.h>
+2 -7
drivers/input/mouse/elan_i2c_core.c
··· 1221 1221 mutex_init(&data->sysfs_mutex); 1222 1222 1223 1223 data->vcc = devm_regulator_get(dev, "vcc"); 1224 - if (IS_ERR(data->vcc)) { 1225 - error = PTR_ERR(data->vcc); 1226 - if (error != -EPROBE_DEFER) 1227 - dev_err(dev, "Failed to get 'vcc' regulator: %d\n", 1228 - error); 1229 - return error; 1230 - } 1224 + if (IS_ERR(data->vcc)) 1225 + return dev_err_probe(dev, PTR_ERR(data->vcc), "Failed to get 'vcc' regulator\n"); 1231 1226 1232 1227 error = regulator_enable(data->vcc); 1233 1228 if (error) {
+12 -7
drivers/input/mouse/psmouse-smbus.c
··· 5 5 6 6 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 7 7 8 + #include <linux/delay.h> 8 9 #include <linux/kernel.h> 9 10 #include <linux/module.h> 10 11 #include <linux/libps2.h> ··· 119 118 return PSMOUSE_FULL_PACKET; 120 119 } 121 120 121 + static void psmouse_activate_smbus_mode(struct psmouse_smbus_dev *smbdev) 122 + { 123 + if (smbdev->need_deactivate) { 124 + psmouse_deactivate(smbdev->psmouse); 125 + /* Give the device time to switch into SMBus mode */ 126 + msleep(30); 127 + } 128 + } 129 + 122 130 static int psmouse_smbus_reconnect(struct psmouse *psmouse) 123 131 { 124 - struct psmouse_smbus_dev *smbdev = psmouse->private; 125 - 126 - if (smbdev->need_deactivate) 127 - psmouse_deactivate(psmouse); 128 - 132 + psmouse_activate_smbus_mode(psmouse->private); 129 133 return 0; 130 134 } 131 135 ··· 263 257 } 264 258 } 265 259 266 - if (need_deactivate) 267 - psmouse_deactivate(psmouse); 260 + psmouse_activate_smbus_mode(smbdev); 268 261 269 262 psmouse->private = smbdev; 270 263 psmouse->protocol_handler = psmouse_smbus_process_byte;
+1 -1
drivers/input/serio/apbps2.c
··· 14 14 * Contributors: Daniel Hellstrom <daniel@gaisler.com> 15 15 */ 16 16 #include <linux/platform_device.h> 17 - #include <linux/of_device.h> 18 17 #include <linux/module.h> 19 18 #include <linux/serio.h> 20 19 #include <linux/errno.h> 21 20 #include <linux/interrupt.h> 21 + #include <linux/of.h> 22 22 #include <linux/of_irq.h> 23 23 #include <linux/device.h> 24 24 #include <linux/delay.h>
+7
drivers/input/serio/i8042-acpipnpio.h
··· 1281 1281 .driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_ALWAYS | 1282 1282 SERIO_QUIRK_NOLOOP | SERIO_QUIRK_NOPNP) 1283 1283 }, 1284 + /* See comment on TUXEDO InfinityBook S17 Gen6 / Clevo NS70MU above */ 1285 + { 1286 + .matches = { 1287 + DMI_MATCH(DMI_BOARD_NAME, "PD5x_7xPNP_PNR_PNN_PNT"), 1288 + }, 1289 + .driver_data = (void *)(SERIO_QUIRK_NOAUX) 1290 + }, 1284 1291 { 1285 1292 .matches = { 1286 1293 DMI_MATCH(DMI_BOARD_NAME, "X170SM"),
+3 -1
drivers/input/serio/i8042-sparcio.h
··· 2 2 #ifndef _I8042_SPARCIO_H 3 3 #define _I8042_SPARCIO_H 4 4 5 - #include <linux/of_device.h> 5 + #include <linux/of.h> 6 + #include <linux/of_platform.h> 7 + #include <linux/platform_device.h> 6 8 #include <linux/types.h> 7 9 8 10 #include <asm/io.h>
+4 -4
drivers/input/serio/rpckbd.c
··· 101 101 int tx_irq, rx_irq; 102 102 103 103 rx_irq = platform_get_irq(dev, 0); 104 - if (rx_irq <= 0) 105 - return rx_irq < 0 ? rx_irq : -ENXIO; 104 + if (rx_irq < 0) 105 + return rx_irq; 106 106 107 107 tx_irq = platform_get_irq(dev, 1); 108 - if (tx_irq <= 0) 109 - return tx_irq < 0 ? tx_irq : -ENXIO; 108 + if (tx_irq < 0) 109 + return tx_irq; 110 110 111 111 serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 112 112 rpckbd = kzalloc(sizeof(*rpckbd), GFP_KERNEL);
+2 -2
drivers/input/serio/xilinx_ps2.c
··· 14 14 #include <linux/slab.h> 15 15 #include <linux/list.h> 16 16 #include <linux/io.h> 17 + #include <linux/mod_devicetable.h> 17 18 #include <linux/of_address.h> 18 - #include <linux/of_device.h> 19 19 #include <linux/of_irq.h> 20 - #include <linux/of_platform.h> 20 + #include <linux/platform_device.h> 21 21 22 22 #define DRIVER_NAME "xilinx_ps2" 23 23
+12 -2
drivers/input/touchscreen/Kconfig
··· 655 655 module will be called mtouch. 656 656 657 657 config TOUCHSCREEN_NOVATEK_NVT_TS 658 - tristate "Novatek NVT-ts touchscreen support" 658 + tristate "Novatek NT11205 touchscreen support" 659 659 depends on I2C 660 660 help 661 - Say Y here if you have a Novatek NVT-ts touchscreen. 661 + Say Y here if you have a Novatek NT11205 touchscreen. 662 662 If unsure, say N. 663 663 664 664 To compile this driver as a module, choose M here: the ··· 1364 1364 1365 1365 To compile this driver as a module, choose M here: the 1366 1366 module will be called iqs5xx. 1367 + 1368 + config TOUCHSCREEN_IQS7211 1369 + tristate "Azoteq IQS7210A/7211A/E trackpad/touchscreen controller" 1370 + depends on I2C 1371 + help 1372 + Say Y to enable support for the Azoteq IQS7210A/7211A/E 1373 + family of trackpad/touchscreen controllers. 1374 + 1375 + To compile this driver as a module, choose M here: the 1376 + module will be called iqs7211. 1367 1377 1368 1378 config TOUCHSCREEN_ZINITIX 1369 1379 tristate "Zinitix touchscreen support"
+1
drivers/input/touchscreen/Makefile
··· 115 115 obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023) += rohm_bu21023.o 116 116 obj-$(CONFIG_TOUCHSCREEN_RASPBERRYPI_FW) += raspberrypi-ts.o 117 117 obj-$(CONFIG_TOUCHSCREEN_IQS5XX) += iqs5xx.o 118 + obj-$(CONFIG_TOUCHSCREEN_IQS7211) += iqs7211.o 118 119 obj-$(CONFIG_TOUCHSCREEN_ZINITIX) += zinitix.o 119 120 obj-$(CONFIG_TOUCHSCREEN_HIMAX_HX83112B) += himax_hx83112b.o
+31 -41
drivers/input/touchscreen/bu21013_ts.c
··· 410 410 struct input_dev *in_dev; 411 411 struct input_absinfo *info; 412 412 u32 max_x = 0, max_y = 0; 413 + struct device *dev = &client->dev; 413 414 int error; 414 415 415 416 if (!i2c_check_functionality(client->adapter, 416 417 I2C_FUNC_SMBUS_BYTE_DATA)) { 417 - dev_err(&client->dev, "i2c smbus byte data not supported\n"); 418 + dev_err(dev, "i2c smbus byte data not supported\n"); 418 419 return -EIO; 419 420 } 420 421 421 422 if (!client->irq) { 422 - dev_err(&client->dev, "No IRQ set up\n"); 423 + dev_err(dev, "No IRQ set up\n"); 423 424 return -EINVAL; 424 425 } 425 426 426 - ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); 427 + ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL); 427 428 if (!ts) 428 429 return -ENOMEM; 429 430 430 431 ts->client = client; 431 432 432 - ts->x_flip = device_property_read_bool(&client->dev, "rohm,flip-x"); 433 - ts->y_flip = device_property_read_bool(&client->dev, "rohm,flip-y"); 433 + ts->x_flip = device_property_read_bool(dev, "rohm,flip-x"); 434 + ts->y_flip = device_property_read_bool(dev, "rohm,flip-y"); 434 435 435 - in_dev = devm_input_allocate_device(&client->dev); 436 + in_dev = devm_input_allocate_device(dev); 436 437 if (!in_dev) { 437 - dev_err(&client->dev, "device memory alloc failed\n"); 438 + dev_err(dev, "device memory alloc failed\n"); 438 439 return -ENOMEM; 439 440 } 440 441 ts->in_dev = in_dev; ··· 445 444 in_dev->name = DRIVER_TP; 446 445 in_dev->id.bustype = BUS_I2C; 447 446 448 - device_property_read_u32(&client->dev, "rohm,touch-max-x", &max_x); 449 - device_property_read_u32(&client->dev, "rohm,touch-max-y", &max_y); 447 + device_property_read_u32(dev, "rohm,touch-max-x", &max_x); 448 + device_property_read_u32(dev, "rohm,touch-max-y", &max_y); 450 449 451 450 input_set_abs_params(in_dev, ABS_MT_POSITION_X, 0, max_x, 0, 0); 452 451 input_set_abs_params(in_dev, ABS_MT_POSITION_Y, 0, max_y, 0, 0); ··· 455 454 456 455 /* Adjust for the legacy "flip" properties, if present */ 457 456 if (!ts->props.invert_x && 458 - device_property_read_bool(&client->dev, "rohm,flip-x")) { 457 + device_property_read_bool(dev, "rohm,flip-x")) { 459 458 info = &in_dev->absinfo[ABS_MT_POSITION_X]; 460 459 info->maximum -= info->minimum; 461 460 info->minimum = 0; 462 461 } 463 462 464 463 if (!ts->props.invert_y && 465 - device_property_read_bool(&client->dev, "rohm,flip-y")) { 464 + device_property_read_bool(dev, "rohm,flip-y")) { 466 465 info = &in_dev->absinfo[ABS_MT_POSITION_Y]; 467 466 info->maximum -= info->minimum; 468 467 info->minimum = 0; ··· 472 471 INPUT_MT_DIRECT | INPUT_MT_TRACK | 473 472 INPUT_MT_DROP_UNUSED); 474 473 if (error) { 475 - dev_err(&client->dev, "failed to initialize MT slots"); 474 + dev_err(dev, "failed to initialize MT slots"); 476 475 return error; 477 476 } 478 477 479 - ts->regulator = devm_regulator_get(&client->dev, "avdd"); 478 + ts->regulator = devm_regulator_get(dev, "avdd"); 480 479 if (IS_ERR(ts->regulator)) { 481 - dev_err(&client->dev, "regulator_get failed\n"); 480 + dev_err(dev, "regulator_get failed\n"); 482 481 return PTR_ERR(ts->regulator); 483 482 } 484 483 485 484 error = regulator_enable(ts->regulator); 486 485 if (error) { 487 - dev_err(&client->dev, "regulator enable failed\n"); 486 + dev_err(dev, "regulator enable failed\n"); 488 487 return error; 489 488 } 490 489 491 - error = devm_add_action_or_reset(&client->dev, bu21013_power_off, ts); 490 + error = devm_add_action_or_reset(dev, bu21013_power_off, ts); 492 491 if (error) { 493 - dev_err(&client->dev, "failed to install power off handler\n"); 492 + dev_err(dev, "failed to install power off handler\n"); 494 493 return error; 495 494 } 496 495 497 496 /* Named "CS" on the chip, DT binding is "reset" */ 498 - ts->cs_gpiod = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH); 499 - error = PTR_ERR_OR_ZERO(ts->cs_gpiod); 500 - if (error) { 501 - if (error != -EPROBE_DEFER) 502 - dev_err(&client->dev, "failed to get CS GPIO\n"); 503 - return error; 504 - } 497 + ts->cs_gpiod = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); 498 + if (IS_ERR(ts->cs_gpiod)) 499 + return dev_err_probe(dev, PTR_ERR(ts->cs_gpiod), "failed to get CS GPIO\n"); 500 + 505 501 gpiod_set_consumer_name(ts->cs_gpiod, "BU21013 CS"); 506 502 507 - error = devm_add_action_or_reset(&client->dev, 508 - bu21013_disable_chip, ts); 503 + error = devm_add_action_or_reset(dev, bu21013_disable_chip, ts); 509 504 if (error) { 510 - dev_err(&client->dev, 511 - "failed to install chip disable handler\n"); 505 + dev_err(dev, "failed to install chip disable handler\n"); 512 506 return error; 513 507 } 514 508 515 509 /* Named "INT" on the chip, DT binding is "touch" */ 516 - ts->int_gpiod = devm_gpiod_get_optional(&client->dev, 517 - "touch", GPIOD_IN); 510 + ts->int_gpiod = devm_gpiod_get_optional(dev, "touch", GPIOD_IN); 518 511 error = PTR_ERR_OR_ZERO(ts->int_gpiod); 519 - if (error) { 520 - if (error != -EPROBE_DEFER) 521 - dev_err(&client->dev, "failed to get INT GPIO\n"); 522 - return error; 523 - } 512 + if (error) 513 + return dev_err_probe(dev, error, "failed to get INT GPIO\n"); 524 514 525 515 if (ts->int_gpiod) 526 516 gpiod_set_consumer_name(ts->int_gpiod, "BU21013 INT"); ··· 519 527 /* configure the touch panel controller */ 520 528 error = bu21013_init_chip(ts); 521 529 if (error) { 522 - dev_err(&client->dev, "error in bu21013 config\n"); 530 + dev_err(dev, "error in bu21013 config\n"); 523 531 return error; 524 532 } 525 533 526 - error = devm_request_threaded_irq(&client->dev, client->irq, 527 - NULL, bu21013_gpio_irq, 534 + error = devm_request_threaded_irq(dev, client->irq, NULL, bu21013_gpio_irq, 528 535 IRQF_ONESHOT, DRIVER_TP, ts); 529 536 if (error) { 530 - dev_err(&client->dev, "request irq %d failed\n", 531 - client->irq); 537 + dev_err(dev, "request irq %d failed\n", client->irq); 532 538 return error; 533 539 } 534 540 535 541 error = input_register_device(in_dev); 536 542 if (error) { 537 - dev_err(&client->dev, "failed to register input device\n"); 543 + dev_err(dev, "failed to register input device\n"); 538 544 return error; 539 545 } 540 546
+19 -32
drivers/input/touchscreen/bu21029_ts.c
··· 333 333 334 334 static int bu21029_probe(struct i2c_client *client) 335 335 { 336 + struct device *dev = &client->dev; 336 337 struct bu21029_ts_data *bu21029; 337 338 struct input_dev *in_dev; 338 339 int error; ··· 342 341 I2C_FUNC_SMBUS_WRITE_BYTE | 343 342 I2C_FUNC_SMBUS_WRITE_BYTE_DATA | 344 343 I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { 345 - dev_err(&client->dev, 346 - "i2c functionality support is not sufficient\n"); 344 + dev_err(dev, "i2c functionality support is not sufficient\n"); 347 345 return -EIO; 348 346 } 349 347 350 - bu21029 = devm_kzalloc(&client->dev, sizeof(*bu21029), GFP_KERNEL); 348 + bu21029 = devm_kzalloc(dev, sizeof(*bu21029), GFP_KERNEL); 351 349 if (!bu21029) 352 350 return -ENOMEM; 353 351 354 - error = device_property_read_u32(&client->dev, "rohm,x-plate-ohms", 355 - &bu21029->x_plate_ohms); 352 + error = device_property_read_u32(dev, "rohm,x-plate-ohms", &bu21029->x_plate_ohms); 356 353 if (error) { 357 - dev_err(&client->dev, 358 - "invalid 'x-plate-ohms' supplied: %d\n", error); 354 + dev_err(dev, "invalid 'x-plate-ohms' supplied: %d\n", error); 359 355 return error; 360 356 } 361 357 362 - bu21029->vdd = devm_regulator_get(&client->dev, "vdd"); 363 - if (IS_ERR(bu21029->vdd)) { 364 - error = PTR_ERR(bu21029->vdd); 365 - if (error != -EPROBE_DEFER) 366 - dev_err(&client->dev, 367 - "failed to acquire 'vdd' supply: %d\n", error); 368 - return error; 369 - } 358 + bu21029->vdd = devm_regulator_get(dev, "vdd"); 359 + if (IS_ERR(bu21029->vdd)) 360 + return dev_err_probe(dev, PTR_ERR(bu21029->vdd), 361 + "failed to acquire 'vdd' supply\n"); 370 362 371 - bu21029->reset_gpios = devm_gpiod_get_optional(&client->dev, 372 - "reset", GPIOD_OUT_HIGH); 373 - if (IS_ERR(bu21029->reset_gpios)) { 374 - error = PTR_ERR(bu21029->reset_gpios); 375 - if (error != -EPROBE_DEFER) 376 - dev_err(&client->dev, 377 - "failed to acquire 'reset' gpio: %d\n", error); 378 - return error; 379 - } 363 + bu21029->reset_gpios = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); 364 + if (IS_ERR(bu21029->reset_gpios)) 365 + return dev_err_probe(dev, PTR_ERR(bu21029->reset_gpios), 366 + "failed to acquire 'reset' gpio\n"); 380 367 381 - in_dev = devm_input_allocate_device(&client->dev); 368 + in_dev = devm_input_allocate_device(dev); 382 369 if (!in_dev) { 383 - dev_err(&client->dev, "unable to allocate input device\n"); 370 + dev_err(dev, "unable to allocate input device\n"); 384 371 return -ENOMEM; 385 372 } 386 373 ··· 389 400 390 401 input_set_drvdata(in_dev, bu21029); 391 402 392 - error = devm_request_threaded_irq(&client->dev, client->irq, 393 - NULL, bu21029_touch_soft_irq, 403 + error = devm_request_threaded_irq(dev, client->irq, NULL, 404 + bu21029_touch_soft_irq, 394 405 IRQF_ONESHOT | IRQF_NO_AUTOEN, 395 406 DRIVER_NAME, bu21029); 396 407 if (error) { 397 - dev_err(&client->dev, 398 - "unable to request touch irq: %d\n", error); 408 + dev_err(dev, "unable to request touch irq: %d\n", error); 399 409 return error; 400 410 } 401 411 402 412 error = input_register_device(in_dev); 403 413 if (error) { 404 - dev_err(&client->dev, 405 - "unable to register input device: %d\n", error); 414 + dev_err(dev, "unable to register input device: %d\n", error); 406 415 return error; 407 416 } 408 417
+2 -6
drivers/input/touchscreen/chipone_icn8318.c
··· 191 191 return -ENOMEM; 192 192 193 193 data->wake_gpio = devm_gpiod_get(dev, "wake", GPIOD_OUT_LOW); 194 - if (IS_ERR(data->wake_gpio)) { 195 - error = PTR_ERR(data->wake_gpio); 196 - if (error != -EPROBE_DEFER) 197 - dev_err(dev, "Error getting wake gpio: %d\n", error); 198 - return error; 199 - } 194 + if (IS_ERR(data->wake_gpio)) 195 + return dev_err_probe(dev, PTR_ERR(data->wake_gpio), "Error getting wake gpio\n"); 200 196 201 197 input = devm_input_allocate_device(dev); 202 198 if (!input)
+2 -6
drivers/input/touchscreen/cy8ctma140.c
··· 258 258 ts->regulators[1].supply = "vdd"; 259 259 error = devm_regulator_bulk_get(dev, ARRAY_SIZE(ts->regulators), 260 260 ts->regulators); 261 - if (error) { 262 - if (error != -EPROBE_DEFER) 263 - dev_err(dev, "Failed to get regulators %d\n", 264 - error); 265 - return error; 266 - } 261 + if (error) 262 + return dev_err_probe(dev, error, "Failed to get regulators\n"); 267 263 268 264 error = cy8ctma140_power_up(ts); 269 265 if (error)
+1 -1
drivers/input/touchscreen/cyttsp5.c
··· 18 18 #include <linux/input/touchscreen.h> 19 19 #include <linux/interrupt.h> 20 20 #include <linux/i2c.h> 21 + #include <linux/mod_devicetable.h> 21 22 #include <linux/module.h> 22 - #include <linux/of_device.h> 23 23 #include <linux/regmap.h> 24 24 #include <asm/unaligned.h> 25 25
+3 -7
drivers/input/touchscreen/edt-ft5x06.c
··· 1168 1168 tsdata->max_support_points = chip_data->max_support_points; 1169 1169 1170 1170 tsdata->vcc = devm_regulator_get(&client->dev, "vcc"); 1171 - if (IS_ERR(tsdata->vcc)) { 1172 - error = PTR_ERR(tsdata->vcc); 1173 - if (error != -EPROBE_DEFER) 1174 - dev_err(&client->dev, 1175 - "failed to request regulator: %d\n", error); 1176 - return error; 1177 - } 1171 + if (IS_ERR(tsdata->vcc)) 1172 + return dev_err_probe(&client->dev, PTR_ERR(tsdata->vcc), 1173 + "failed to request regulator\n"); 1178 1174 1179 1175 tsdata->iovcc = devm_regulator_get(&client->dev, "iovcc"); 1180 1176 if (IS_ERR(tsdata->iovcc)) {
+2 -6
drivers/input/touchscreen/ektf2127.c
··· 264 264 265 265 /* This requests the gpio *and* turns on the touchscreen controller */ 266 266 ts->power_gpios = devm_gpiod_get(dev, "power", GPIOD_OUT_HIGH); 267 - if (IS_ERR(ts->power_gpios)) { 268 - error = PTR_ERR(ts->power_gpios); 269 - if (error != -EPROBE_DEFER) 270 - dev_err(dev, "Error getting power gpio: %d\n", error); 271 - return error; 272 - } 267 + if (IS_ERR(ts->power_gpios)) 268 + return dev_err_probe(dev, PTR_ERR(ts->power_gpios), "Error getting power gpio\n"); 273 269 274 270 input = devm_input_allocate_device(dev); 275 271 if (!input)
+6 -16
drivers/input/touchscreen/elants_i2c.c
··· 1438 1438 i2c_set_clientdata(client, ts); 1439 1439 1440 1440 ts->vcc33 = devm_regulator_get(&client->dev, "vcc33"); 1441 - if (IS_ERR(ts->vcc33)) { 1442 - error = PTR_ERR(ts->vcc33); 1443 - if (error != -EPROBE_DEFER) 1444 - dev_err(&client->dev, 1445 - "Failed to get 'vcc33' regulator: %d\n", 1446 - error); 1447 - return error; 1448 - } 1441 + if (IS_ERR(ts->vcc33)) 1442 + return dev_err_probe(&client->dev, PTR_ERR(ts->vcc33), 1443 + "Failed to get 'vcc33' regulator\n"); 1449 1444 1450 1445 ts->vccio = devm_regulator_get(&client->dev, "vccio"); 1451 - if (IS_ERR(ts->vccio)) { 1452 - error = PTR_ERR(ts->vccio); 1453 - if (error != -EPROBE_DEFER) 1454 - dev_err(&client->dev, 1455 - "Failed to get 'vccio' regulator: %d\n", 1456 - error); 1457 - return error; 1458 - } 1446 + if (IS_ERR(ts->vccio)) 1447 + return dev_err_probe(&client->dev, PTR_ERR(ts->vccio), 1448 + "Failed to get 'vccio' regulator\n"); 1459 1449 1460 1450 ts->reset_gpio = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH); 1461 1451 if (IS_ERR(ts->reset_gpio)) {
+17
drivers/input/touchscreen/exc3000.c
··· 7 7 * minimal implementation based on egalax_ts.c and egalax_i2c.c 8 8 */ 9 9 10 + #include <linux/acpi.h> 10 11 #include <linux/bitops.h> 11 12 #include <linux/delay.h> 12 13 #include <linux/device.h> ··· 19 18 #include <linux/interrupt.h> 20 19 #include <linux/module.h> 21 20 #include <linux/of.h> 21 + #include <linux/regulator/consumer.h> 22 22 #include <linux/sizes.h> 23 23 #include <linux/timer.h> 24 24 #include <asm/unaligned.h> ··· 362 360 if (IS_ERR(data->reset)) 363 361 return PTR_ERR(data->reset); 364 362 363 + /* For proper reset sequence, enable power while reset asserted */ 364 + error = devm_regulator_get_enable(&client->dev, "vdd"); 365 + if (error && error != -ENODEV) 366 + return dev_err_probe(&client->dev, error, 367 + "failed to request vdd regulator\n"); 368 + 365 369 if (data->reset) { 366 370 msleep(EXC3000_RESET_MS); 367 371 gpiod_set_value_cansleep(data->reset, 0); ··· 462 454 MODULE_DEVICE_TABLE(of, exc3000_of_match); 463 455 #endif 464 456 457 + #ifdef CONFIG_ACPI 458 + static const struct acpi_device_id exc3000_acpi_match[] = { 459 + { "EGA00001", .driver_data = (kernel_ulong_t)&exc3000_info[EETI_EXC80H60] }, 460 + { } 461 + }; 462 + MODULE_DEVICE_TABLE(acpi, exc3000_acpi_match); 463 + #endif 464 + 465 465 static struct i2c_driver exc3000_driver = { 466 466 .driver = { 467 467 .name = "exc3000", 468 468 .of_match_table = of_match_ptr(exc3000_of_match), 469 + .acpi_match_table = ACPI_PTR(exc3000_acpi_match), 469 470 }, 470 471 .id_table = exc3000_id, 471 472 .probe = exc3000_probe,
+12 -29
drivers/input/touchscreen/goodix.c
··· 935 935 */ 936 936 static int goodix_get_gpio_config(struct goodix_ts_data *ts) 937 937 { 938 - int error; 939 938 struct device *dev; 940 939 struct gpio_desc *gpiod; 941 940 bool added_acpi_mappings = false; ··· 950 951 ts->gpiod_rst_flags = GPIOD_IN; 951 952 952 953 ts->avdd28 = devm_regulator_get(dev, "AVDD28"); 953 - if (IS_ERR(ts->avdd28)) { 954 - error = PTR_ERR(ts->avdd28); 955 - if (error != -EPROBE_DEFER) 956 - dev_err(dev, 957 - "Failed to get AVDD28 regulator: %d\n", error); 958 - return error; 959 - } 954 + if (IS_ERR(ts->avdd28)) 955 + return dev_err_probe(dev, PTR_ERR(ts->avdd28), "Failed to get AVDD28 regulator\n"); 960 956 961 957 ts->vddio = devm_regulator_get(dev, "VDDIO"); 962 - if (IS_ERR(ts->vddio)) { 963 - error = PTR_ERR(ts->vddio); 964 - if (error != -EPROBE_DEFER) 965 - dev_err(dev, 966 - "Failed to get VDDIO regulator: %d\n", error); 967 - return error; 968 - } 958 + if (IS_ERR(ts->vddio)) 959 + return dev_err_probe(dev, PTR_ERR(ts->vddio), "Failed to get VDDIO regulator\n"); 969 960 970 961 retry_get_irq_gpio: 971 962 /* Get the interrupt GPIO pin number */ 972 963 gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_INT_NAME, GPIOD_IN); 973 - if (IS_ERR(gpiod)) { 974 - error = PTR_ERR(gpiod); 975 - if (error != -EPROBE_DEFER) 976 - dev_err(dev, "Failed to get %s GPIO: %d\n", 977 - GOODIX_GPIO_INT_NAME, error); 978 - return error; 979 - } 964 + if (IS_ERR(gpiod)) 965 + return dev_err_probe(dev, PTR_ERR(gpiod), "Failed to get %s GPIO\n", 966 + GOODIX_GPIO_INT_NAME); 967 + 980 968 if (!gpiod && has_acpi_companion(dev) && !added_acpi_mappings) { 981 969 added_acpi_mappings = true; 982 970 if (goodix_add_acpi_gpio_mappings(ts) == 0) ··· 974 988 975 989 /* Get the reset line GPIO pin number */ 976 990 gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_RST_NAME, ts->gpiod_rst_flags); 977 - if (IS_ERR(gpiod)) { 978 - error = PTR_ERR(gpiod); 979 - if (error != -EPROBE_DEFER) 980 - dev_err(dev, "Failed to get %s GPIO: %d\n", 981 - GOODIX_GPIO_RST_NAME, error); 982 - return error; 983 - } 991 + if (IS_ERR(gpiod)) 992 + return dev_err_probe(dev, PTR_ERR(gpiod), "Failed to get %s GPIO\n", 993 + GOODIX_GPIO_RST_NAME); 984 994 985 995 ts->gpiod_rst = gpiod; 986 996 ··· 1499 1517 static const struct acpi_device_id goodix_acpi_match[] = { 1500 1518 { "GDIX1001", 0 }, 1501 1519 { "GDIX1002", 0 }, 1520 + { "GDX9110", 0 }, 1502 1521 { } 1503 1522 }; 1504 1523 MODULE_DEVICE_TABLE(acpi, goodix_acpi_match);
+1 -1
drivers/input/touchscreen/ili210x.c
··· 8 8 #include <linux/input/mt.h> 9 9 #include <linux/input/touchscreen.h> 10 10 #include <linux/interrupt.h> 11 + #include <linux/mod_devicetable.h> 11 12 #include <linux/module.h> 12 - #include <linux/of_device.h> 13 13 #include <linux/sizes.h> 14 14 #include <linux/slab.h> 15 15 #include <asm/unaligned.h>
+1 -1
drivers/input/touchscreen/iqs5xx.c
··· 23 23 #include <linux/input/touchscreen.h> 24 24 #include <linux/interrupt.h> 25 25 #include <linux/kernel.h> 26 + #include <linux/mod_devicetable.h> 26 27 #include <linux/module.h> 27 - #include <linux/of_device.h> 28 28 #include <linux/slab.h> 29 29 #include <asm/unaligned.h> 30 30
+2557
drivers/input/touchscreen/iqs7211.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* 3 + * Azoteq IQS7210A/7211A/E Trackpad/Touchscreen Controller 4 + * 5 + * Copyright (C) 2023 Jeff LaBundy <jeff@labundy.com> 6 + */ 7 + 8 + #include <linux/bits.h> 9 + #include <linux/delay.h> 10 + #include <linux/device.h> 11 + #include <linux/err.h> 12 + #include <linux/gpio/consumer.h> 13 + #include <linux/i2c.h> 14 + #include <linux/input.h> 15 + #include <linux/input/mt.h> 16 + #include <linux/input/touchscreen.h> 17 + #include <linux/interrupt.h> 18 + #include <linux/iopoll.h> 19 + #include <linux/kernel.h> 20 + #include <linux/list.h> 21 + #include <linux/module.h> 22 + #include <linux/of_device.h> 23 + #include <linux/property.h> 24 + #include <linux/slab.h> 25 + #include <asm/unaligned.h> 26 + 27 + #define IQS7211_PROD_NUM 0x00 28 + 29 + #define IQS7211_EVENT_MASK_ALL GENMASK(14, 8) 30 + #define IQS7211_EVENT_MASK_ALP BIT(13) 31 + #define IQS7211_EVENT_MASK_BTN BIT(12) 32 + #define IQS7211_EVENT_MASK_ATI BIT(11) 33 + #define IQS7211_EVENT_MASK_MOVE BIT(10) 34 + #define IQS7211_EVENT_MASK_GSTR BIT(9) 35 + #define IQS7211_EVENT_MODE BIT(8) 36 + 37 + #define IQS7211_COMMS_ERROR 0xEEEE 38 + #define IQS7211_COMMS_RETRY_MS 50 39 + #define IQS7211_COMMS_SLEEP_US 100 40 + #define IQS7211_COMMS_TIMEOUT_US (100 * USEC_PER_MSEC) 41 + #define IQS7211_RESET_TIMEOUT_MS 150 42 + #define IQS7211_START_TIMEOUT_US (1 * USEC_PER_SEC) 43 + 44 + #define IQS7211_NUM_RETRIES 5 45 + #define IQS7211_NUM_CRX 8 46 + #define IQS7211_MAX_CTX 13 47 + 48 + #define IQS7211_MAX_CONTACTS 2 49 + #define IQS7211_MAX_CYCLES 21 50 + 51 + /* 52 + * The following delay is used during instances that must wait for the open- 53 + * drain RDY pin to settle. Its value is calculated as 5*R*C, where R and C 54 + * represent typical datasheet values of 4.7k and 100 nF, respectively. 55 + */ 56 + #define iqs7211_irq_wait() usleep_range(2500, 2600) 57 + 58 + enum iqs7211_dev_id { 59 + IQS7210A, 60 + IQS7211A, 61 + IQS7211E, 62 + }; 63 + 64 + enum iqs7211_comms_mode { 65 + IQS7211_COMMS_MODE_WAIT, 66 + IQS7211_COMMS_MODE_FREE, 67 + IQS7211_COMMS_MODE_FORCE, 68 + }; 69 + 70 + struct iqs7211_reg_field_desc { 71 + struct list_head list; 72 + u8 addr; 73 + u16 mask; 74 + u16 val; 75 + }; 76 + 77 + enum iqs7211_reg_key_id { 78 + IQS7211_REG_KEY_NONE, 79 + IQS7211_REG_KEY_PROX, 80 + IQS7211_REG_KEY_TOUCH, 81 + IQS7211_REG_KEY_TAP, 82 + IQS7211_REG_KEY_HOLD, 83 + IQS7211_REG_KEY_PALM, 84 + IQS7211_REG_KEY_AXIAL_X, 85 + IQS7211_REG_KEY_AXIAL_Y, 86 + IQS7211_REG_KEY_RESERVED 87 + }; 88 + 89 + enum iqs7211_reg_grp_id { 90 + IQS7211_REG_GRP_TP, 91 + IQS7211_REG_GRP_BTN, 92 + IQS7211_REG_GRP_ALP, 93 + IQS7211_REG_GRP_SYS, 94 + IQS7211_NUM_REG_GRPS 95 + }; 96 + 97 + static const char * const iqs7211_reg_grp_names[IQS7211_NUM_REG_GRPS] = { 98 + [IQS7211_REG_GRP_TP] = "trackpad", 99 + [IQS7211_REG_GRP_BTN] = "button", 100 + [IQS7211_REG_GRP_ALP] = "alp", 101 + }; 102 + 103 + static const u16 iqs7211_reg_grp_masks[IQS7211_NUM_REG_GRPS] = { 104 + [IQS7211_REG_GRP_TP] = IQS7211_EVENT_MASK_GSTR, 105 + [IQS7211_REG_GRP_BTN] = IQS7211_EVENT_MASK_BTN, 106 + [IQS7211_REG_GRP_ALP] = IQS7211_EVENT_MASK_ALP, 107 + }; 108 + 109 + struct iqs7211_event_desc { 110 + const char *name; 111 + u16 mask; 112 + u16 enable; 113 + enum iqs7211_reg_grp_id reg_grp; 114 + enum iqs7211_reg_key_id reg_key; 115 + }; 116 + 117 + static const struct iqs7211_event_desc iqs7210a_kp_events[] = { 118 + { 119 + .mask = BIT(10), 120 + .enable = BIT(13) | BIT(12), 121 + .reg_grp = IQS7211_REG_GRP_ALP, 122 + }, 123 + { 124 + .name = "event-prox", 125 + .mask = BIT(2), 126 + .enable = BIT(5) | BIT(4), 127 + .reg_grp = IQS7211_REG_GRP_BTN, 128 + .reg_key = IQS7211_REG_KEY_PROX, 129 + }, 130 + { 131 + .name = "event-touch", 132 + .mask = BIT(3), 133 + .enable = BIT(5) | BIT(4), 134 + .reg_grp = IQS7211_REG_GRP_BTN, 135 + .reg_key = IQS7211_REG_KEY_TOUCH, 136 + }, 137 + { 138 + .name = "event-tap", 139 + .mask = BIT(0), 140 + .enable = BIT(0), 141 + .reg_grp = IQS7211_REG_GRP_TP, 142 + .reg_key = IQS7211_REG_KEY_TAP, 143 + }, 144 + { 145 + .name = "event-hold", 146 + .mask = BIT(1), 147 + .enable = BIT(1), 148 + .reg_grp = IQS7211_REG_GRP_TP, 149 + .reg_key = IQS7211_REG_KEY_HOLD, 150 + }, 151 + { 152 + .name = "event-swipe-x-neg", 153 + .mask = BIT(2), 154 + .enable = BIT(2), 155 + .reg_grp = IQS7211_REG_GRP_TP, 156 + .reg_key = IQS7211_REG_KEY_AXIAL_X, 157 + }, 158 + { 159 + .name = "event-swipe-x-pos", 160 + .mask = BIT(3), 161 + .enable = BIT(3), 162 + .reg_grp = IQS7211_REG_GRP_TP, 163 + .reg_key = IQS7211_REG_KEY_AXIAL_X, 164 + }, 165 + { 166 + .name = "event-swipe-y-pos", 167 + .mask = BIT(4), 168 + .enable = BIT(4), 169 + .reg_grp = IQS7211_REG_GRP_TP, 170 + .reg_key = IQS7211_REG_KEY_AXIAL_Y, 171 + }, 172 + { 173 + .name = "event-swipe-y-neg", 174 + .mask = BIT(5), 175 + .enable = BIT(5), 176 + .reg_grp = IQS7211_REG_GRP_TP, 177 + .reg_key = IQS7211_REG_KEY_AXIAL_Y, 178 + }, 179 + }; 180 + 181 + static const struct iqs7211_event_desc iqs7211a_kp_events[] = { 182 + { 183 + .mask = BIT(14), 184 + .reg_grp = IQS7211_REG_GRP_ALP, 185 + }, 186 + { 187 + .name = "event-tap", 188 + .mask = BIT(0), 189 + .enable = BIT(0), 190 + .reg_grp = IQS7211_REG_GRP_TP, 191 + .reg_key = IQS7211_REG_KEY_TAP, 192 + }, 193 + { 194 + .name = "event-hold", 195 + .mask = BIT(1), 196 + .enable = BIT(1), 197 + .reg_grp = IQS7211_REG_GRP_TP, 198 + .reg_key = IQS7211_REG_KEY_HOLD, 199 + }, 200 + { 201 + .name = "event-swipe-x-neg", 202 + .mask = BIT(2), 203 + .enable = BIT(2), 204 + .reg_grp = IQS7211_REG_GRP_TP, 205 + .reg_key = IQS7211_REG_KEY_AXIAL_X, 206 + }, 207 + { 208 + .name = "event-swipe-x-pos", 209 + .mask = BIT(3), 210 + .enable = BIT(3), 211 + .reg_grp = IQS7211_REG_GRP_TP, 212 + .reg_key = IQS7211_REG_KEY_AXIAL_X, 213 + }, 214 + { 215 + .name = "event-swipe-y-pos", 216 + .mask = BIT(4), 217 + .enable = BIT(4), 218 + .reg_grp = IQS7211_REG_GRP_TP, 219 + .reg_key = IQS7211_REG_KEY_AXIAL_Y, 220 + }, 221 + { 222 + .name = "event-swipe-y-neg", 223 + .mask = BIT(5), 224 + .enable = BIT(5), 225 + .reg_grp = IQS7211_REG_GRP_TP, 226 + .reg_key = IQS7211_REG_KEY_AXIAL_Y, 227 + }, 228 + }; 229 + 230 + static const struct iqs7211_event_desc iqs7211e_kp_events[] = { 231 + { 232 + .mask = BIT(14), 233 + .reg_grp = IQS7211_REG_GRP_ALP, 234 + }, 235 + { 236 + .name = "event-tap", 237 + .mask = BIT(0), 238 + .enable = BIT(0), 239 + .reg_grp = IQS7211_REG_GRP_TP, 240 + .reg_key = IQS7211_REG_KEY_TAP, 241 + }, 242 + { 243 + .name = "event-tap-double", 244 + .mask = BIT(1), 245 + .enable = BIT(1), 246 + .reg_grp = IQS7211_REG_GRP_TP, 247 + .reg_key = IQS7211_REG_KEY_TAP, 248 + }, 249 + { 250 + .name = "event-tap-triple", 251 + .mask = BIT(2), 252 + .enable = BIT(2), 253 + .reg_grp = IQS7211_REG_GRP_TP, 254 + .reg_key = IQS7211_REG_KEY_TAP, 255 + }, 256 + { 257 + .name = "event-hold", 258 + .mask = BIT(3), 259 + .enable = BIT(3), 260 + .reg_grp = IQS7211_REG_GRP_TP, 261 + .reg_key = IQS7211_REG_KEY_HOLD, 262 + }, 263 + { 264 + .name = "event-palm", 265 + .mask = BIT(4), 266 + .enable = BIT(4), 267 + .reg_grp = IQS7211_REG_GRP_TP, 268 + .reg_key = IQS7211_REG_KEY_PALM, 269 + }, 270 + { 271 + .name = "event-swipe-x-pos", 272 + .mask = BIT(8), 273 + .enable = BIT(8), 274 + .reg_grp = IQS7211_REG_GRP_TP, 275 + .reg_key = IQS7211_REG_KEY_AXIAL_X, 276 + }, 277 + { 278 + .name = "event-swipe-x-neg", 279 + .mask = BIT(9), 280 + .enable = BIT(9), 281 + .reg_grp = IQS7211_REG_GRP_TP, 282 + .reg_key = IQS7211_REG_KEY_AXIAL_X, 283 + }, 284 + { 285 + .name = "event-swipe-y-pos", 286 + .mask = BIT(10), 287 + .enable = BIT(10), 288 + .reg_grp = IQS7211_REG_GRP_TP, 289 + .reg_key = IQS7211_REG_KEY_AXIAL_Y, 290 + }, 291 + { 292 + .name = "event-swipe-y-neg", 293 + .mask = BIT(11), 294 + .enable = BIT(11), 295 + .reg_grp = IQS7211_REG_GRP_TP, 296 + .reg_key = IQS7211_REG_KEY_AXIAL_Y, 297 + }, 298 + { 299 + .name = "event-swipe-x-pos-hold", 300 + .mask = BIT(12), 301 + .enable = BIT(12), 302 + .reg_grp = IQS7211_REG_GRP_TP, 303 + .reg_key = IQS7211_REG_KEY_HOLD, 304 + }, 305 + { 306 + .name = "event-swipe-x-neg-hold", 307 + .mask = BIT(13), 308 + .enable = BIT(13), 309 + .reg_grp = IQS7211_REG_GRP_TP, 310 + .reg_key = IQS7211_REG_KEY_HOLD, 311 + }, 312 + { 313 + .name = "event-swipe-y-pos-hold", 314 + .mask = BIT(14), 315 + .enable = BIT(14), 316 + .reg_grp = IQS7211_REG_GRP_TP, 317 + .reg_key = IQS7211_REG_KEY_HOLD, 318 + }, 319 + { 320 + .name = "event-swipe-y-neg-hold", 321 + .mask = BIT(15), 322 + .enable = BIT(15), 323 + .reg_grp = IQS7211_REG_GRP_TP, 324 + .reg_key = IQS7211_REG_KEY_HOLD, 325 + }, 326 + }; 327 + 328 + struct iqs7211_dev_desc { 329 + const char *tp_name; 330 + const char *kp_name; 331 + u16 prod_num; 332 + u16 show_reset; 333 + u16 ati_error[IQS7211_NUM_REG_GRPS]; 334 + u16 ati_start[IQS7211_NUM_REG_GRPS]; 335 + u16 suspend; 336 + u16 ack_reset; 337 + u16 comms_end; 338 + u16 comms_req; 339 + int charge_shift; 340 + int info_offs; 341 + int gesture_offs; 342 + int contact_offs; 343 + u8 sys_stat; 344 + u8 sys_ctrl; 345 + u8 alp_config; 346 + u8 tp_config; 347 + u8 exp_file; 348 + u8 kp_enable[IQS7211_NUM_REG_GRPS]; 349 + u8 gesture_angle; 350 + u8 rx_tx_map; 351 + u8 cycle_alloc[2]; 352 + u8 cycle_limit[2]; 353 + const struct iqs7211_event_desc *kp_events; 354 + int num_kp_events; 355 + int min_crx_alp; 356 + int num_ctx; 357 + }; 358 + 359 + static const struct iqs7211_dev_desc iqs7211_devs[] = { 360 + [IQS7210A] = { 361 + .tp_name = "iqs7210a_trackpad", 362 + .kp_name = "iqs7210a_keys", 363 + .prod_num = 944, 364 + .show_reset = BIT(15), 365 + .ati_error = { 366 + [IQS7211_REG_GRP_TP] = BIT(12), 367 + [IQS7211_REG_GRP_BTN] = BIT(0), 368 + [IQS7211_REG_GRP_ALP] = BIT(8), 369 + }, 370 + .ati_start = { 371 + [IQS7211_REG_GRP_TP] = BIT(13), 372 + [IQS7211_REG_GRP_BTN] = BIT(1), 373 + [IQS7211_REG_GRP_ALP] = BIT(9), 374 + }, 375 + .suspend = BIT(11), 376 + .ack_reset = BIT(7), 377 + .comms_end = BIT(2), 378 + .comms_req = BIT(1), 379 + .charge_shift = 4, 380 + .info_offs = 0, 381 + .gesture_offs = 1, 382 + .contact_offs = 4, 383 + .sys_stat = 0x0A, 384 + .sys_ctrl = 0x35, 385 + .alp_config = 0x39, 386 + .tp_config = 0x4E, 387 + .exp_file = 0x57, 388 + .kp_enable = { 389 + [IQS7211_REG_GRP_TP] = 0x58, 390 + [IQS7211_REG_GRP_BTN] = 0x37, 391 + [IQS7211_REG_GRP_ALP] = 0x37, 392 + }, 393 + .gesture_angle = 0x5F, 394 + .rx_tx_map = 0x60, 395 + .cycle_alloc = { 0x66, 0x75, }, 396 + .cycle_limit = { 10, 6, }, 397 + .kp_events = iqs7210a_kp_events, 398 + .num_kp_events = ARRAY_SIZE(iqs7210a_kp_events), 399 + .min_crx_alp = 4, 400 + .num_ctx = IQS7211_MAX_CTX - 1, 401 + }, 402 + [IQS7211A] = { 403 + .tp_name = "iqs7211a_trackpad", 404 + .kp_name = "iqs7211a_keys", 405 + .prod_num = 763, 406 + .show_reset = BIT(7), 407 + .ati_error = { 408 + [IQS7211_REG_GRP_TP] = BIT(3), 409 + [IQS7211_REG_GRP_ALP] = BIT(5), 410 + }, 411 + .ati_start = { 412 + [IQS7211_REG_GRP_TP] = BIT(5), 413 + [IQS7211_REG_GRP_ALP] = BIT(6), 414 + }, 415 + .ack_reset = BIT(7), 416 + .comms_req = BIT(4), 417 + .charge_shift = 0, 418 + .info_offs = 0, 419 + .gesture_offs = 1, 420 + .contact_offs = 4, 421 + .sys_stat = 0x10, 422 + .sys_ctrl = 0x50, 423 + .tp_config = 0x60, 424 + .alp_config = 0x72, 425 + .exp_file = 0x74, 426 + .kp_enable = { 427 + [IQS7211_REG_GRP_TP] = 0x80, 428 + }, 429 + .gesture_angle = 0x87, 430 + .rx_tx_map = 0x90, 431 + .cycle_alloc = { 0xA0, 0xB0, }, 432 + .cycle_limit = { 10, 8, }, 433 + .kp_events = iqs7211a_kp_events, 434 + .num_kp_events = ARRAY_SIZE(iqs7211a_kp_events), 435 + .num_ctx = IQS7211_MAX_CTX - 1, 436 + }, 437 + [IQS7211E] = { 438 + .tp_name = "iqs7211e_trackpad", 439 + .kp_name = "iqs7211e_keys", 440 + .prod_num = 1112, 441 + .show_reset = BIT(7), 442 + .ati_error = { 443 + [IQS7211_REG_GRP_TP] = BIT(3), 444 + [IQS7211_REG_GRP_ALP] = BIT(5), 445 + }, 446 + .ati_start = { 447 + [IQS7211_REG_GRP_TP] = BIT(5), 448 + [IQS7211_REG_GRP_ALP] = BIT(6), 449 + }, 450 + .suspend = BIT(11), 451 + .ack_reset = BIT(7), 452 + .comms_end = BIT(6), 453 + .comms_req = BIT(4), 454 + .charge_shift = 0, 455 + .info_offs = 1, 456 + .gesture_offs = 0, 457 + .contact_offs = 2, 458 + .sys_stat = 0x0E, 459 + .sys_ctrl = 0x33, 460 + .tp_config = 0x41, 461 + .alp_config = 0x36, 462 + .exp_file = 0x4A, 463 + .kp_enable = { 464 + [IQS7211_REG_GRP_TP] = 0x4B, 465 + }, 466 + .gesture_angle = 0x55, 467 + .rx_tx_map = 0x56, 468 + .cycle_alloc = { 0x5D, 0x6C, }, 469 + .cycle_limit = { 10, 11, }, 470 + .kp_events = iqs7211e_kp_events, 471 + .num_kp_events = ARRAY_SIZE(iqs7211e_kp_events), 472 + .num_ctx = IQS7211_MAX_CTX, 473 + }, 474 + }; 475 + 476 + struct iqs7211_prop_desc { 477 + const char *name; 478 + enum iqs7211_reg_key_id reg_key; 479 + u8 reg_addr[IQS7211_NUM_REG_GRPS][ARRAY_SIZE(iqs7211_devs)]; 480 + int reg_shift; 481 + int reg_width; 482 + int val_pitch; 483 + int val_min; 484 + int val_max; 485 + const char *label; 486 + }; 487 + 488 + static const struct iqs7211_prop_desc iqs7211_props[] = { 489 + { 490 + .name = "azoteq,ati-frac-div-fine", 491 + .reg_addr = { 492 + [IQS7211_REG_GRP_TP] = { 493 + [IQS7210A] = 0x1E, 494 + [IQS7211A] = 0x30, 495 + [IQS7211E] = 0x21, 496 + }, 497 + [IQS7211_REG_GRP_BTN] = { 498 + [IQS7210A] = 0x22, 499 + }, 500 + [IQS7211_REG_GRP_ALP] = { 501 + [IQS7210A] = 0x23, 502 + [IQS7211A] = 0x36, 503 + [IQS7211E] = 0x25, 504 + }, 505 + }, 506 + .reg_shift = 9, 507 + .reg_width = 5, 508 + .label = "ATI fine fractional divider", 509 + }, 510 + { 511 + .name = "azoteq,ati-frac-mult-coarse", 512 + .reg_addr = { 513 + [IQS7211_REG_GRP_TP] = { 514 + [IQS7210A] = 0x1E, 515 + [IQS7211A] = 0x30, 516 + [IQS7211E] = 0x21, 517 + }, 518 + [IQS7211_REG_GRP_BTN] = { 519 + [IQS7210A] = 0x22, 520 + }, 521 + [IQS7211_REG_GRP_ALP] = { 522 + [IQS7210A] = 0x23, 523 + [IQS7211A] = 0x36, 524 + [IQS7211E] = 0x25, 525 + }, 526 + }, 527 + .reg_shift = 5, 528 + .reg_width = 4, 529 + .label = "ATI coarse fractional multiplier", 530 + }, 531 + { 532 + .name = "azoteq,ati-frac-div-coarse", 533 + .reg_addr = { 534 + [IQS7211_REG_GRP_TP] = { 535 + [IQS7210A] = 0x1E, 536 + [IQS7211A] = 0x30, 537 + [IQS7211E] = 0x21, 538 + }, 539 + [IQS7211_REG_GRP_BTN] = { 540 + [IQS7210A] = 0x22, 541 + }, 542 + [IQS7211_REG_GRP_ALP] = { 543 + [IQS7210A] = 0x23, 544 + [IQS7211A] = 0x36, 545 + [IQS7211E] = 0x25, 546 + }, 547 + }, 548 + .reg_shift = 0, 549 + .reg_width = 5, 550 + .label = "ATI coarse fractional divider", 551 + }, 552 + { 553 + .name = "azoteq,ati-comp-div", 554 + .reg_addr = { 555 + [IQS7211_REG_GRP_TP] = { 556 + [IQS7210A] = 0x1F, 557 + [IQS7211E] = 0x22, 558 + }, 559 + [IQS7211_REG_GRP_BTN] = { 560 + [IQS7210A] = 0x24, 561 + }, 562 + [IQS7211_REG_GRP_ALP] = { 563 + [IQS7211E] = 0x26, 564 + }, 565 + }, 566 + .reg_shift = 0, 567 + .reg_width = 8, 568 + .val_max = 31, 569 + .label = "ATI compensation divider", 570 + }, 571 + { 572 + .name = "azoteq,ati-comp-div", 573 + .reg_addr = { 574 + [IQS7211_REG_GRP_ALP] = { 575 + [IQS7210A] = 0x24, 576 + }, 577 + }, 578 + .reg_shift = 8, 579 + .reg_width = 8, 580 + .val_max = 31, 581 + .label = "ATI compensation divider", 582 + }, 583 + { 584 + .name = "azoteq,ati-comp-div", 585 + .reg_addr = { 586 + [IQS7211_REG_GRP_TP] = { 587 + [IQS7211A] = 0x31, 588 + }, 589 + [IQS7211_REG_GRP_ALP] = { 590 + [IQS7211A] = 0x37, 591 + }, 592 + }, 593 + .val_max = 31, 594 + .label = "ATI compensation divider", 595 + }, 596 + { 597 + .name = "azoteq,ati-target", 598 + .reg_addr = { 599 + [IQS7211_REG_GRP_TP] = { 600 + [IQS7210A] = 0x20, 601 + [IQS7211A] = 0x32, 602 + [IQS7211E] = 0x23, 603 + }, 604 + [IQS7211_REG_GRP_BTN] = { 605 + [IQS7210A] = 0x27, 606 + }, 607 + [IQS7211_REG_GRP_ALP] = { 608 + [IQS7210A] = 0x28, 609 + [IQS7211A] = 0x38, 610 + [IQS7211E] = 0x27, 611 + }, 612 + }, 613 + .label = "ATI target", 614 + }, 615 + { 616 + .name = "azoteq,ati-base", 617 + .reg_addr[IQS7211_REG_GRP_ALP] = { 618 + [IQS7210A] = 0x26, 619 + }, 620 + .reg_shift = 8, 621 + .reg_width = 8, 622 + .val_pitch = 8, 623 + .label = "ATI base", 624 + }, 625 + { 626 + .name = "azoteq,ati-base", 627 + .reg_addr[IQS7211_REG_GRP_BTN] = { 628 + [IQS7210A] = 0x26, 629 + }, 630 + .reg_shift = 0, 631 + .reg_width = 8, 632 + .val_pitch = 8, 633 + .label = "ATI base", 634 + }, 635 + { 636 + .name = "azoteq,rate-active-ms", 637 + .reg_addr[IQS7211_REG_GRP_SYS] = { 638 + [IQS7210A] = 0x29, 639 + [IQS7211A] = 0x40, 640 + [IQS7211E] = 0x28, 641 + }, 642 + .label = "active mode report rate", 643 + }, 644 + { 645 + .name = "azoteq,rate-touch-ms", 646 + .reg_addr[IQS7211_REG_GRP_SYS] = { 647 + [IQS7210A] = 0x2A, 648 + [IQS7211A] = 0x41, 649 + [IQS7211E] = 0x29, 650 + }, 651 + .label = "idle-touch mode report rate", 652 + }, 653 + { 654 + .name = "azoteq,rate-idle-ms", 655 + .reg_addr[IQS7211_REG_GRP_SYS] = { 656 + [IQS7210A] = 0x2B, 657 + [IQS7211A] = 0x42, 658 + [IQS7211E] = 0x2A, 659 + }, 660 + .label = "idle mode report rate", 661 + }, 662 + { 663 + .name = "azoteq,rate-lp1-ms", 664 + .reg_addr[IQS7211_REG_GRP_SYS] = { 665 + [IQS7210A] = 0x2C, 666 + [IQS7211A] = 0x43, 667 + [IQS7211E] = 0x2B, 668 + }, 669 + .label = "low-power mode 1 report rate", 670 + }, 671 + { 672 + .name = "azoteq,rate-lp2-ms", 673 + .reg_addr[IQS7211_REG_GRP_SYS] = { 674 + [IQS7210A] = 0x2D, 675 + [IQS7211A] = 0x44, 676 + [IQS7211E] = 0x2C, 677 + }, 678 + .label = "low-power mode 2 report rate", 679 + }, 680 + { 681 + .name = "azoteq,timeout-active-ms", 682 + .reg_addr[IQS7211_REG_GRP_SYS] = { 683 + [IQS7210A] = 0x2E, 684 + [IQS7211A] = 0x45, 685 + [IQS7211E] = 0x2D, 686 + }, 687 + .val_pitch = 1000, 688 + .label = "active mode timeout", 689 + }, 690 + { 691 + .name = "azoteq,timeout-touch-ms", 692 + .reg_addr[IQS7211_REG_GRP_SYS] = { 693 + [IQS7210A] = 0x2F, 694 + [IQS7211A] = 0x46, 695 + [IQS7211E] = 0x2E, 696 + }, 697 + .val_pitch = 1000, 698 + .label = "idle-touch mode timeout", 699 + }, 700 + { 701 + .name = "azoteq,timeout-idle-ms", 702 + .reg_addr[IQS7211_REG_GRP_SYS] = { 703 + [IQS7210A] = 0x30, 704 + [IQS7211A] = 0x47, 705 + [IQS7211E] = 0x2F, 706 + }, 707 + .val_pitch = 1000, 708 + .label = "idle mode timeout", 709 + }, 710 + { 711 + .name = "azoteq,timeout-lp1-ms", 712 + .reg_addr[IQS7211_REG_GRP_SYS] = { 713 + [IQS7210A] = 0x31, 714 + [IQS7211A] = 0x48, 715 + [IQS7211E] = 0x30, 716 + }, 717 + .val_pitch = 1000, 718 + .label = "low-power mode 1 timeout", 719 + }, 720 + { 721 + .name = "azoteq,timeout-lp2-ms", 722 + .reg_addr[IQS7211_REG_GRP_SYS] = { 723 + [IQS7210A] = 0x32, 724 + [IQS7211E] = 0x31, 725 + }, 726 + .reg_shift = 8, 727 + .reg_width = 8, 728 + .val_pitch = 1000, 729 + .val_max = 60000, 730 + .label = "trackpad reference value update rate", 731 + }, 732 + { 733 + .name = "azoteq,timeout-lp2-ms", 734 + .reg_addr[IQS7211_REG_GRP_SYS] = { 735 + [IQS7211A] = 0x49, 736 + }, 737 + .val_pitch = 1000, 738 + .val_max = 60000, 739 + .label = "trackpad reference value update rate", 740 + }, 741 + { 742 + .name = "azoteq,timeout-ati-ms", 743 + .reg_addr[IQS7211_REG_GRP_SYS] = { 744 + [IQS7210A] = 0x32, 745 + [IQS7211E] = 0x31, 746 + }, 747 + .reg_width = 8, 748 + .val_pitch = 1000, 749 + .val_max = 60000, 750 + .label = "ATI error timeout", 751 + }, 752 + { 753 + .name = "azoteq,timeout-ati-ms", 754 + .reg_addr[IQS7211_REG_GRP_SYS] = { 755 + [IQS7211A] = 0x35, 756 + }, 757 + .val_pitch = 1000, 758 + .val_max = 60000, 759 + .label = "ATI error timeout", 760 + }, 761 + { 762 + .name = "azoteq,timeout-comms-ms", 763 + .reg_addr[IQS7211_REG_GRP_SYS] = { 764 + [IQS7210A] = 0x33, 765 + [IQS7211A] = 0x4A, 766 + [IQS7211E] = 0x32, 767 + }, 768 + .label = "communication timeout", 769 + }, 770 + { 771 + .name = "azoteq,timeout-press-ms", 772 + .reg_addr[IQS7211_REG_GRP_SYS] = { 773 + [IQS7210A] = 0x34, 774 + }, 775 + .reg_width = 8, 776 + .val_pitch = 1000, 777 + .val_max = 60000, 778 + .label = "press timeout", 779 + }, 780 + { 781 + .name = "azoteq,ati-mode", 782 + .reg_addr[IQS7211_REG_GRP_ALP] = { 783 + [IQS7210A] = 0x37, 784 + }, 785 + .reg_shift = 15, 786 + .reg_width = 1, 787 + .label = "ATI mode", 788 + }, 789 + { 790 + .name = "azoteq,ati-mode", 791 + .reg_addr[IQS7211_REG_GRP_BTN] = { 792 + [IQS7210A] = 0x37, 793 + }, 794 + .reg_shift = 7, 795 + .reg_width = 1, 796 + .label = "ATI mode", 797 + }, 798 + { 799 + .name = "azoteq,sense-mode", 800 + .reg_addr[IQS7211_REG_GRP_ALP] = { 801 + [IQS7210A] = 0x37, 802 + [IQS7211A] = 0x72, 803 + [IQS7211E] = 0x36, 804 + }, 805 + .reg_shift = 8, 806 + .reg_width = 1, 807 + .label = "sensing mode", 808 + }, 809 + { 810 + .name = "azoteq,sense-mode", 811 + .reg_addr[IQS7211_REG_GRP_BTN] = { 812 + [IQS7210A] = 0x37, 813 + }, 814 + .reg_shift = 0, 815 + .reg_width = 2, 816 + .val_max = 2, 817 + .label = "sensing mode", 818 + }, 819 + { 820 + .name = "azoteq,fosc-freq", 821 + .reg_addr[IQS7211_REG_GRP_SYS] = { 822 + [IQS7210A] = 0x38, 823 + [IQS7211A] = 0x52, 824 + [IQS7211E] = 0x35, 825 + }, 826 + .reg_shift = 4, 827 + .reg_width = 1, 828 + .label = "core clock frequency selection", 829 + }, 830 + { 831 + .name = "azoteq,fosc-trim", 832 + .reg_addr[IQS7211_REG_GRP_SYS] = { 833 + [IQS7210A] = 0x38, 834 + [IQS7211A] = 0x52, 835 + [IQS7211E] = 0x35, 836 + }, 837 + .reg_shift = 0, 838 + .reg_width = 4, 839 + .label = "core clock frequency trim", 840 + }, 841 + { 842 + .name = "azoteq,touch-exit", 843 + .reg_addr = { 844 + [IQS7211_REG_GRP_TP] = { 845 + [IQS7210A] = 0x3B, 846 + [IQS7211A] = 0x53, 847 + [IQS7211E] = 0x38, 848 + }, 849 + [IQS7211_REG_GRP_BTN] = { 850 + [IQS7210A] = 0x3E, 851 + }, 852 + }, 853 + .reg_shift = 8, 854 + .reg_width = 8, 855 + .label = "touch exit factor", 856 + }, 857 + { 858 + .name = "azoteq,touch-enter", 859 + .reg_addr = { 860 + [IQS7211_REG_GRP_TP] = { 861 + [IQS7210A] = 0x3B, 862 + [IQS7211A] = 0x53, 863 + [IQS7211E] = 0x38, 864 + }, 865 + [IQS7211_REG_GRP_BTN] = { 866 + [IQS7210A] = 0x3E, 867 + }, 868 + }, 869 + .reg_shift = 0, 870 + .reg_width = 8, 871 + .label = "touch entrance factor", 872 + }, 873 + { 874 + .name = "azoteq,thresh", 875 + .reg_addr = { 876 + [IQS7211_REG_GRP_BTN] = { 877 + [IQS7210A] = 0x3C, 878 + }, 879 + [IQS7211_REG_GRP_ALP] = { 880 + [IQS7210A] = 0x3D, 881 + [IQS7211A] = 0x54, 882 + [IQS7211E] = 0x39, 883 + }, 884 + }, 885 + .label = "threshold", 886 + }, 887 + { 888 + .name = "azoteq,debounce-exit", 889 + .reg_addr = { 890 + [IQS7211_REG_GRP_BTN] = { 891 + [IQS7210A] = 0x3F, 892 + }, 893 + [IQS7211_REG_GRP_ALP] = { 894 + [IQS7210A] = 0x40, 895 + [IQS7211A] = 0x56, 896 + [IQS7211E] = 0x3A, 897 + }, 898 + }, 899 + .reg_shift = 8, 900 + .reg_width = 8, 901 + .label = "debounce exit factor", 902 + }, 903 + { 904 + .name = "azoteq,debounce-enter", 905 + .reg_addr = { 906 + [IQS7211_REG_GRP_BTN] = { 907 + [IQS7210A] = 0x3F, 908 + }, 909 + [IQS7211_REG_GRP_ALP] = { 910 + [IQS7210A] = 0x40, 911 + [IQS7211A] = 0x56, 912 + [IQS7211E] = 0x3A, 913 + }, 914 + }, 915 + .reg_shift = 0, 916 + .reg_width = 8, 917 + .label = "debounce entrance factor", 918 + }, 919 + { 920 + .name = "azoteq,conv-frac", 921 + .reg_addr = { 922 + [IQS7211_REG_GRP_TP] = { 923 + [IQS7210A] = 0x48, 924 + [IQS7211A] = 0x58, 925 + [IQS7211E] = 0x3D, 926 + }, 927 + [IQS7211_REG_GRP_BTN] = { 928 + [IQS7210A] = 0x49, 929 + }, 930 + [IQS7211_REG_GRP_ALP] = { 931 + [IQS7210A] = 0x4A, 932 + [IQS7211A] = 0x59, 933 + [IQS7211E] = 0x3E, 934 + }, 935 + }, 936 + .reg_shift = 8, 937 + .reg_width = 8, 938 + .label = "conversion frequency fractional divider", 939 + }, 940 + { 941 + .name = "azoteq,conv-period", 942 + .reg_addr = { 943 + [IQS7211_REG_GRP_TP] = { 944 + [IQS7210A] = 0x48, 945 + [IQS7211A] = 0x58, 946 + [IQS7211E] = 0x3D, 947 + }, 948 + [IQS7211_REG_GRP_BTN] = { 949 + [IQS7210A] = 0x49, 950 + }, 951 + [IQS7211_REG_GRP_ALP] = { 952 + [IQS7210A] = 0x4A, 953 + [IQS7211A] = 0x59, 954 + [IQS7211E] = 0x3E, 955 + }, 956 + }, 957 + .reg_shift = 0, 958 + .reg_width = 8, 959 + .label = "conversion period", 960 + }, 961 + { 962 + .name = "azoteq,thresh", 963 + .reg_addr[IQS7211_REG_GRP_TP] = { 964 + [IQS7210A] = 0x55, 965 + [IQS7211A] = 0x67, 966 + [IQS7211E] = 0x48, 967 + }, 968 + .reg_shift = 0, 969 + .reg_width = 8, 970 + .label = "threshold", 971 + }, 972 + { 973 + .name = "azoteq,contact-split", 974 + .reg_addr[IQS7211_REG_GRP_SYS] = { 975 + [IQS7210A] = 0x55, 976 + [IQS7211A] = 0x67, 977 + [IQS7211E] = 0x48, 978 + }, 979 + .reg_shift = 8, 980 + .reg_width = 8, 981 + .label = "contact split factor", 982 + }, 983 + { 984 + .name = "azoteq,trim-x", 985 + .reg_addr[IQS7211_REG_GRP_SYS] = { 986 + [IQS7210A] = 0x56, 987 + [IQS7211E] = 0x49, 988 + }, 989 + .reg_shift = 0, 990 + .reg_width = 8, 991 + .label = "horizontal trim width", 992 + }, 993 + { 994 + .name = "azoteq,trim-x", 995 + .reg_addr[IQS7211_REG_GRP_SYS] = { 996 + [IQS7211A] = 0x68, 997 + }, 998 + .label = "horizontal trim width", 999 + }, 1000 + { 1001 + .name = "azoteq,trim-y", 1002 + .reg_addr[IQS7211_REG_GRP_SYS] = { 1003 + [IQS7210A] = 0x56, 1004 + [IQS7211E] = 0x49, 1005 + }, 1006 + .reg_shift = 8, 1007 + .reg_width = 8, 1008 + .label = "vertical trim height", 1009 + }, 1010 + { 1011 + .name = "azoteq,trim-y", 1012 + .reg_addr[IQS7211_REG_GRP_SYS] = { 1013 + [IQS7211A] = 0x69, 1014 + }, 1015 + .label = "vertical trim height", 1016 + }, 1017 + { 1018 + .name = "azoteq,gesture-max-ms", 1019 + .reg_key = IQS7211_REG_KEY_TAP, 1020 + .reg_addr[IQS7211_REG_GRP_TP] = { 1021 + [IQS7210A] = 0x59, 1022 + [IQS7211A] = 0x81, 1023 + [IQS7211E] = 0x4C, 1024 + }, 1025 + .label = "maximum gesture time", 1026 + }, 1027 + { 1028 + .name = "azoteq,gesture-mid-ms", 1029 + .reg_key = IQS7211_REG_KEY_TAP, 1030 + .reg_addr[IQS7211_REG_GRP_TP] = { 1031 + [IQS7211E] = 0x4D, 1032 + }, 1033 + .label = "repeated gesture time", 1034 + }, 1035 + { 1036 + .name = "azoteq,gesture-dist", 1037 + .reg_key = IQS7211_REG_KEY_TAP, 1038 + .reg_addr[IQS7211_REG_GRP_TP] = { 1039 + [IQS7210A] = 0x5A, 1040 + [IQS7211A] = 0x82, 1041 + [IQS7211E] = 0x4E, 1042 + }, 1043 + .label = "gesture distance", 1044 + }, 1045 + { 1046 + .name = "azoteq,gesture-dist", 1047 + .reg_key = IQS7211_REG_KEY_HOLD, 1048 + .reg_addr[IQS7211_REG_GRP_TP] = { 1049 + [IQS7210A] = 0x5A, 1050 + [IQS7211A] = 0x82, 1051 + [IQS7211E] = 0x4E, 1052 + }, 1053 + .label = "gesture distance", 1054 + }, 1055 + { 1056 + .name = "azoteq,gesture-min-ms", 1057 + .reg_key = IQS7211_REG_KEY_HOLD, 1058 + .reg_addr[IQS7211_REG_GRP_TP] = { 1059 + [IQS7210A] = 0x5B, 1060 + [IQS7211A] = 0x83, 1061 + [IQS7211E] = 0x4F, 1062 + }, 1063 + .label = "minimum gesture time", 1064 + }, 1065 + { 1066 + .name = "azoteq,gesture-max-ms", 1067 + .reg_key = IQS7211_REG_KEY_AXIAL_X, 1068 + .reg_addr[IQS7211_REG_GRP_TP] = { 1069 + [IQS7210A] = 0x5C, 1070 + [IQS7211A] = 0x84, 1071 + [IQS7211E] = 0x50, 1072 + }, 1073 + .label = "maximum gesture time", 1074 + }, 1075 + { 1076 + .name = "azoteq,gesture-max-ms", 1077 + .reg_key = IQS7211_REG_KEY_AXIAL_Y, 1078 + .reg_addr[IQS7211_REG_GRP_TP] = { 1079 + [IQS7210A] = 0x5C, 1080 + [IQS7211A] = 0x84, 1081 + [IQS7211E] = 0x50, 1082 + }, 1083 + .label = "maximum gesture time", 1084 + }, 1085 + { 1086 + .name = "azoteq,gesture-dist", 1087 + .reg_key = IQS7211_REG_KEY_AXIAL_X, 1088 + .reg_addr[IQS7211_REG_GRP_TP] = { 1089 + [IQS7210A] = 0x5D, 1090 + [IQS7211A] = 0x85, 1091 + [IQS7211E] = 0x51, 1092 + }, 1093 + .label = "gesture distance", 1094 + }, 1095 + { 1096 + .name = "azoteq,gesture-dist", 1097 + .reg_key = IQS7211_REG_KEY_AXIAL_Y, 1098 + .reg_addr[IQS7211_REG_GRP_TP] = { 1099 + [IQS7210A] = 0x5E, 1100 + [IQS7211A] = 0x86, 1101 + [IQS7211E] = 0x52, 1102 + }, 1103 + .label = "gesture distance", 1104 + }, 1105 + { 1106 + .name = "azoteq,gesture-dist-rep", 1107 + .reg_key = IQS7211_REG_KEY_AXIAL_X, 1108 + .reg_addr[IQS7211_REG_GRP_TP] = { 1109 + [IQS7211E] = 0x53, 1110 + }, 1111 + .label = "repeated gesture distance", 1112 + }, 1113 + { 1114 + .name = "azoteq,gesture-dist-rep", 1115 + .reg_key = IQS7211_REG_KEY_AXIAL_Y, 1116 + .reg_addr[IQS7211_REG_GRP_TP] = { 1117 + [IQS7211E] = 0x54, 1118 + }, 1119 + .label = "repeated gesture distance", 1120 + }, 1121 + { 1122 + .name = "azoteq,thresh", 1123 + .reg_key = IQS7211_REG_KEY_PALM, 1124 + .reg_addr[IQS7211_REG_GRP_TP] = { 1125 + [IQS7211E] = 0x55, 1126 + }, 1127 + .reg_shift = 8, 1128 + .reg_width = 8, 1129 + .val_max = 42, 1130 + .label = "threshold", 1131 + }, 1132 + }; 1133 + 1134 + static const u8 iqs7211_gesture_angle[] = { 1135 + 0x00, 0x01, 0x02, 0x03, 1136 + 0x04, 0x06, 0x07, 0x08, 1137 + 0x09, 0x0A, 0x0B, 0x0C, 1138 + 0x0E, 0x0F, 0x10, 0x11, 1139 + 0x12, 0x14, 0x15, 0x16, 1140 + 0x17, 0x19, 0x1A, 0x1B, 1141 + 0x1C, 0x1E, 0x1F, 0x21, 1142 + 0x22, 0x23, 0x25, 0x26, 1143 + 0x28, 0x2A, 0x2B, 0x2D, 1144 + 0x2E, 0x30, 0x32, 0x34, 1145 + 0x36, 0x38, 0x3A, 0x3C, 1146 + 0x3E, 0x40, 0x42, 0x45, 1147 + 0x47, 0x4A, 0x4C, 0x4F, 1148 + 0x52, 0x55, 0x58, 0x5B, 1149 + 0x5F, 0x63, 0x66, 0x6B, 1150 + 0x6F, 0x73, 0x78, 0x7E, 1151 + 0x83, 0x89, 0x90, 0x97, 1152 + 0x9E, 0xA7, 0xB0, 0xBA, 1153 + 0xC5, 0xD1, 0xDF, 0xEF, 1154 + }; 1155 + 1156 + struct iqs7211_ver_info { 1157 + __le16 prod_num; 1158 + __le16 major; 1159 + __le16 minor; 1160 + __le32 patch; 1161 + } __packed; 1162 + 1163 + struct iqs7211_touch_data { 1164 + __le16 abs_x; 1165 + __le16 abs_y; 1166 + __le16 pressure; 1167 + __le16 area; 1168 + } __packed; 1169 + 1170 + struct iqs7211_tp_config { 1171 + u8 tp_settings; 1172 + u8 total_rx; 1173 + u8 total_tx; 1174 + u8 num_contacts; 1175 + __le16 max_x; 1176 + __le16 max_y; 1177 + } __packed; 1178 + 1179 + struct iqs7211_private { 1180 + const struct iqs7211_dev_desc *dev_desc; 1181 + struct gpio_desc *reset_gpio; 1182 + struct gpio_desc *irq_gpio; 1183 + struct i2c_client *client; 1184 + struct input_dev *tp_idev; 1185 + struct input_dev *kp_idev; 1186 + struct iqs7211_ver_info ver_info; 1187 + struct iqs7211_tp_config tp_config; 1188 + struct touchscreen_properties prop; 1189 + struct list_head reg_field_head; 1190 + enum iqs7211_comms_mode comms_init; 1191 + enum iqs7211_comms_mode comms_mode; 1192 + unsigned int num_contacts; 1193 + unsigned int kp_code[ARRAY_SIZE(iqs7211e_kp_events)]; 1194 + u8 rx_tx_map[IQS7211_MAX_CTX + 1]; 1195 + u8 cycle_alloc[2][33]; 1196 + u8 exp_file[2]; 1197 + u16 event_mask; 1198 + u16 ati_start; 1199 + u16 gesture_cache; 1200 + }; 1201 + 1202 + static int iqs7211_irq_poll(struct iqs7211_private *iqs7211, u64 timeout_us) 1203 + { 1204 + int error, val; 1205 + 1206 + error = readx_poll_timeout(gpiod_get_value_cansleep, iqs7211->irq_gpio, 1207 + val, val, IQS7211_COMMS_SLEEP_US, timeout_us); 1208 + 1209 + return val < 0 ? val : error; 1210 + } 1211 + 1212 + static int iqs7211_hard_reset(struct iqs7211_private *iqs7211) 1213 + { 1214 + if (!iqs7211->reset_gpio) 1215 + return 0; 1216 + 1217 + gpiod_set_value_cansleep(iqs7211->reset_gpio, 1); 1218 + 1219 + /* 1220 + * The following delay ensures the shared RDY/MCLR pin is sampled in 1221 + * between periodic assertions by the device and assumes the default 1222 + * communication timeout has not been overwritten in OTP memory. 1223 + */ 1224 + if (iqs7211->reset_gpio == iqs7211->irq_gpio) 1225 + msleep(IQS7211_RESET_TIMEOUT_MS); 1226 + else 1227 + usleep_range(1000, 1100); 1228 + 1229 + gpiod_set_value_cansleep(iqs7211->reset_gpio, 0); 1230 + if (iqs7211->reset_gpio == iqs7211->irq_gpio) 1231 + iqs7211_irq_wait(); 1232 + 1233 + return iqs7211_irq_poll(iqs7211, IQS7211_START_TIMEOUT_US); 1234 + } 1235 + 1236 + static int iqs7211_force_comms(struct iqs7211_private *iqs7211) 1237 + { 1238 + u8 msg_buf[] = { 0xFF, }; 1239 + int ret; 1240 + 1241 + switch (iqs7211->comms_mode) { 1242 + case IQS7211_COMMS_MODE_WAIT: 1243 + return iqs7211_irq_poll(iqs7211, IQS7211_START_TIMEOUT_US); 1244 + 1245 + case IQS7211_COMMS_MODE_FREE: 1246 + return 0; 1247 + 1248 + case IQS7211_COMMS_MODE_FORCE: 1249 + break; 1250 + 1251 + default: 1252 + return -EINVAL; 1253 + } 1254 + 1255 + /* 1256 + * The device cannot communicate until it asserts its interrupt (RDY) 1257 + * pin. Attempts to do so while RDY is deasserted return an ACK; how- 1258 + * ever all write data is ignored, and all read data returns 0xEE. 1259 + * 1260 + * Unsolicited communication must be preceded by a special force com- 1261 + * munication command, after which the device eventually asserts its 1262 + * RDY pin and agrees to communicate. 1263 + * 1264 + * Regardless of whether communication is forced or the result of an 1265 + * interrupt, the device automatically deasserts its RDY pin once it 1266 + * detects an I2C stop condition, or a timeout expires. 1267 + */ 1268 + ret = gpiod_get_value_cansleep(iqs7211->irq_gpio); 1269 + if (ret < 0) 1270 + return ret; 1271 + else if (ret > 0) 1272 + return 0; 1273 + 1274 + ret = i2c_master_send(iqs7211->client, msg_buf, sizeof(msg_buf)); 1275 + if (ret < (int)sizeof(msg_buf)) { 1276 + if (ret >= 0) 1277 + ret = -EIO; 1278 + 1279 + msleep(IQS7211_COMMS_RETRY_MS); 1280 + return ret; 1281 + } 1282 + 1283 + iqs7211_irq_wait(); 1284 + 1285 + return iqs7211_irq_poll(iqs7211, IQS7211_COMMS_TIMEOUT_US); 1286 + } 1287 + 1288 + static int iqs7211_read_burst(struct iqs7211_private *iqs7211, 1289 + u8 reg, void *val, u16 val_len) 1290 + { 1291 + int ret, i; 1292 + struct i2c_client *client = iqs7211->client; 1293 + struct i2c_msg msg[] = { 1294 + { 1295 + .addr = client->addr, 1296 + .flags = 0, 1297 + .len = sizeof(reg), 1298 + .buf = &reg, 1299 + }, 1300 + { 1301 + .addr = client->addr, 1302 + .flags = I2C_M_RD, 1303 + .len = val_len, 1304 + .buf = (u8 *)val, 1305 + }, 1306 + }; 1307 + 1308 + /* 1309 + * The following loop protects against an edge case in which the RDY 1310 + * pin is automatically deasserted just as the read is initiated. In 1311 + * that case, the read must be retried using forced communication. 1312 + */ 1313 + for (i = 0; i < IQS7211_NUM_RETRIES; i++) { 1314 + ret = iqs7211_force_comms(iqs7211); 1315 + if (ret < 0) 1316 + continue; 1317 + 1318 + ret = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg)); 1319 + if (ret < (int)ARRAY_SIZE(msg)) { 1320 + if (ret >= 0) 1321 + ret = -EIO; 1322 + 1323 + msleep(IQS7211_COMMS_RETRY_MS); 1324 + continue; 1325 + } 1326 + 1327 + if (get_unaligned_le16(msg[1].buf) == IQS7211_COMMS_ERROR) { 1328 + ret = -ENODATA; 1329 + continue; 1330 + } 1331 + 1332 + ret = 0; 1333 + break; 1334 + } 1335 + 1336 + iqs7211_irq_wait(); 1337 + 1338 + if (ret < 0) 1339 + dev_err(&client->dev, 1340 + "Failed to read from address 0x%02X: %d\n", reg, ret); 1341 + 1342 + return ret; 1343 + } 1344 + 1345 + static int iqs7211_read_word(struct iqs7211_private *iqs7211, u8 reg, u16 *val) 1346 + { 1347 + __le16 val_buf; 1348 + int error; 1349 + 1350 + error = iqs7211_read_burst(iqs7211, reg, &val_buf, sizeof(val_buf)); 1351 + if (error) 1352 + return error; 1353 + 1354 + *val = le16_to_cpu(val_buf); 1355 + 1356 + return 0; 1357 + } 1358 + 1359 + static int iqs7211_write_burst(struct iqs7211_private *iqs7211, 1360 + u8 reg, const void *val, u16 val_len) 1361 + { 1362 + int msg_len = sizeof(reg) + val_len; 1363 + int ret, i; 1364 + struct i2c_client *client = iqs7211->client; 1365 + u8 *msg_buf; 1366 + 1367 + msg_buf = kzalloc(msg_len, GFP_KERNEL); 1368 + if (!msg_buf) 1369 + return -ENOMEM; 1370 + 1371 + *msg_buf = reg; 1372 + memcpy(msg_buf + sizeof(reg), val, val_len); 1373 + 1374 + /* 1375 + * The following loop protects against an edge case in which the RDY 1376 + * pin is automatically asserted just before the force communication 1377 + * command is sent. 1378 + * 1379 + * In that case, the subsequent I2C stop condition tricks the device 1380 + * into preemptively deasserting the RDY pin and the command must be 1381 + * sent again. 1382 + */ 1383 + for (i = 0; i < IQS7211_NUM_RETRIES; i++) { 1384 + ret = iqs7211_force_comms(iqs7211); 1385 + if (ret < 0) 1386 + continue; 1387 + 1388 + ret = i2c_master_send(client, msg_buf, msg_len); 1389 + if (ret < msg_len) { 1390 + if (ret >= 0) 1391 + ret = -EIO; 1392 + 1393 + msleep(IQS7211_COMMS_RETRY_MS); 1394 + continue; 1395 + } 1396 + 1397 + ret = 0; 1398 + break; 1399 + } 1400 + 1401 + kfree(msg_buf); 1402 + 1403 + iqs7211_irq_wait(); 1404 + 1405 + if (ret < 0) 1406 + dev_err(&client->dev, 1407 + "Failed to write to address 0x%02X: %d\n", reg, ret); 1408 + 1409 + return ret; 1410 + } 1411 + 1412 + static int iqs7211_write_word(struct iqs7211_private *iqs7211, u8 reg, u16 val) 1413 + { 1414 + __le16 val_buf = cpu_to_le16(val); 1415 + 1416 + return iqs7211_write_burst(iqs7211, reg, &val_buf, sizeof(val_buf)); 1417 + } 1418 + 1419 + static int iqs7211_start_comms(struct iqs7211_private *iqs7211) 1420 + { 1421 + const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; 1422 + struct i2c_client *client = iqs7211->client; 1423 + bool forced_comms; 1424 + unsigned int val; 1425 + u16 comms_setup; 1426 + int error; 1427 + 1428 + /* 1429 + * Until forced communication can be enabled, the host must wait for a 1430 + * communication window each time it intends to elicit a response from 1431 + * the device. 1432 + * 1433 + * Forced communication is not necessary, however, if the host adapter 1434 + * can support clock stretching. In that case, the device freely clock 1435 + * stretches until all pending conversions are complete. 1436 + */ 1437 + forced_comms = device_property_present(&client->dev, 1438 + "azoteq,forced-comms"); 1439 + 1440 + error = device_property_read_u32(&client->dev, 1441 + "azoteq,forced-comms-default", &val); 1442 + if (error == -EINVAL) { 1443 + iqs7211->comms_init = IQS7211_COMMS_MODE_WAIT; 1444 + } else if (error) { 1445 + dev_err(&client->dev, 1446 + "Failed to read default communication mode: %d\n", 1447 + error); 1448 + return error; 1449 + } else if (val) { 1450 + iqs7211->comms_init = forced_comms ? IQS7211_COMMS_MODE_FORCE 1451 + : IQS7211_COMMS_MODE_WAIT; 1452 + } else { 1453 + iqs7211->comms_init = forced_comms ? IQS7211_COMMS_MODE_WAIT 1454 + : IQS7211_COMMS_MODE_FREE; 1455 + } 1456 + 1457 + iqs7211->comms_mode = iqs7211->comms_init; 1458 + 1459 + error = iqs7211_hard_reset(iqs7211); 1460 + if (error) { 1461 + dev_err(&client->dev, "Failed to reset device: %d\n", error); 1462 + return error; 1463 + } 1464 + 1465 + error = iqs7211_read_burst(iqs7211, IQS7211_PROD_NUM, 1466 + &iqs7211->ver_info, 1467 + sizeof(iqs7211->ver_info)); 1468 + if (error) 1469 + return error; 1470 + 1471 + if (le16_to_cpu(iqs7211->ver_info.prod_num) != dev_desc->prod_num) { 1472 + dev_err(&client->dev, "Invalid product number: %u\n", 1473 + le16_to_cpu(iqs7211->ver_info.prod_num)); 1474 + return -EINVAL; 1475 + } 1476 + 1477 + error = iqs7211_read_word(iqs7211, dev_desc->sys_ctrl + 1, 1478 + &comms_setup); 1479 + if (error) 1480 + return error; 1481 + 1482 + if (forced_comms) 1483 + comms_setup |= dev_desc->comms_req; 1484 + else 1485 + comms_setup &= ~dev_desc->comms_req; 1486 + 1487 + error = iqs7211_write_word(iqs7211, dev_desc->sys_ctrl + 1, 1488 + comms_setup | dev_desc->comms_end); 1489 + if (error) 1490 + return error; 1491 + 1492 + if (forced_comms) 1493 + iqs7211->comms_mode = IQS7211_COMMS_MODE_FORCE; 1494 + else 1495 + iqs7211->comms_mode = IQS7211_COMMS_MODE_FREE; 1496 + 1497 + error = iqs7211_read_burst(iqs7211, dev_desc->exp_file, 1498 + iqs7211->exp_file, 1499 + sizeof(iqs7211->exp_file)); 1500 + if (error) 1501 + return error; 1502 + 1503 + error = iqs7211_read_burst(iqs7211, dev_desc->tp_config, 1504 + &iqs7211->tp_config, 1505 + sizeof(iqs7211->tp_config)); 1506 + if (error) 1507 + return error; 1508 + 1509 + error = iqs7211_write_word(iqs7211, dev_desc->sys_ctrl + 1, 1510 + comms_setup); 1511 + if (error) 1512 + return error; 1513 + 1514 + iqs7211->event_mask = comms_setup & ~IQS7211_EVENT_MASK_ALL; 1515 + iqs7211->event_mask |= (IQS7211_EVENT_MASK_ATI | IQS7211_EVENT_MODE); 1516 + 1517 + return 0; 1518 + } 1519 + 1520 + static int iqs7211_init_device(struct iqs7211_private *iqs7211) 1521 + { 1522 + const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; 1523 + struct iqs7211_reg_field_desc *reg_field; 1524 + __le16 sys_ctrl[] = { 1525 + cpu_to_le16(dev_desc->ack_reset), 1526 + cpu_to_le16(iqs7211->event_mask), 1527 + }; 1528 + int error, i; 1529 + 1530 + /* 1531 + * Acknowledge reset before writing any registers in case the device 1532 + * suffers a spurious reset during initialization. The communication 1533 + * mode is configured at this time as well. 1534 + */ 1535 + error = iqs7211_write_burst(iqs7211, dev_desc->sys_ctrl, sys_ctrl, 1536 + sizeof(sys_ctrl)); 1537 + if (error) 1538 + return error; 1539 + 1540 + if (iqs7211->event_mask & dev_desc->comms_req) 1541 + iqs7211->comms_mode = IQS7211_COMMS_MODE_FORCE; 1542 + else 1543 + iqs7211->comms_mode = IQS7211_COMMS_MODE_FREE; 1544 + 1545 + /* 1546 + * Take advantage of the stop-bit disable function, if available, to 1547 + * save the trouble of having to reopen a communication window after 1548 + * each read or write. 1549 + */ 1550 + error = iqs7211_write_word(iqs7211, dev_desc->sys_ctrl + 1, 1551 + iqs7211->event_mask | dev_desc->comms_end); 1552 + if (error) 1553 + return error; 1554 + 1555 + list_for_each_entry(reg_field, &iqs7211->reg_field_head, list) { 1556 + u16 new_val = reg_field->val; 1557 + 1558 + if (reg_field->mask < U16_MAX) { 1559 + u16 old_val; 1560 + 1561 + error = iqs7211_read_word(iqs7211, reg_field->addr, 1562 + &old_val); 1563 + if (error) 1564 + return error; 1565 + 1566 + new_val = old_val & ~reg_field->mask; 1567 + new_val |= reg_field->val; 1568 + 1569 + if (new_val == old_val) 1570 + continue; 1571 + } 1572 + 1573 + error = iqs7211_write_word(iqs7211, reg_field->addr, new_val); 1574 + if (error) 1575 + return error; 1576 + } 1577 + 1578 + error = iqs7211_write_burst(iqs7211, dev_desc->tp_config, 1579 + &iqs7211->tp_config, 1580 + sizeof(iqs7211->tp_config)); 1581 + if (error) 1582 + return error; 1583 + 1584 + if (**iqs7211->cycle_alloc) { 1585 + error = iqs7211_write_burst(iqs7211, dev_desc->rx_tx_map, 1586 + &iqs7211->rx_tx_map, 1587 + dev_desc->num_ctx); 1588 + if (error) 1589 + return error; 1590 + 1591 + for (i = 0; i < sizeof(dev_desc->cycle_limit); i++) { 1592 + error = iqs7211_write_burst(iqs7211, 1593 + dev_desc->cycle_alloc[i], 1594 + iqs7211->cycle_alloc[i], 1595 + dev_desc->cycle_limit[i] * 3); 1596 + if (error) 1597 + return error; 1598 + } 1599 + } 1600 + 1601 + *sys_ctrl = cpu_to_le16(iqs7211->ati_start); 1602 + 1603 + return iqs7211_write_burst(iqs7211, dev_desc->sys_ctrl, sys_ctrl, 1604 + sizeof(sys_ctrl)); 1605 + } 1606 + 1607 + static int iqs7211_add_field(struct iqs7211_private *iqs7211, 1608 + struct iqs7211_reg_field_desc new_field) 1609 + { 1610 + struct i2c_client *client = iqs7211->client; 1611 + struct iqs7211_reg_field_desc *reg_field; 1612 + 1613 + if (!new_field.addr) 1614 + return 0; 1615 + 1616 + list_for_each_entry(reg_field, &iqs7211->reg_field_head, list) { 1617 + if (reg_field->addr != new_field.addr) 1618 + continue; 1619 + 1620 + reg_field->mask |= new_field.mask; 1621 + reg_field->val |= new_field.val; 1622 + return 0; 1623 + } 1624 + 1625 + reg_field = devm_kzalloc(&client->dev, sizeof(*reg_field), GFP_KERNEL); 1626 + if (!reg_field) 1627 + return -ENOMEM; 1628 + 1629 + reg_field->addr = new_field.addr; 1630 + reg_field->mask = new_field.mask; 1631 + reg_field->val = new_field.val; 1632 + 1633 + list_add(&reg_field->list, &iqs7211->reg_field_head); 1634 + 1635 + return 0; 1636 + } 1637 + 1638 + static int iqs7211_parse_props(struct iqs7211_private *iqs7211, 1639 + struct fwnode_handle *reg_grp_node, 1640 + enum iqs7211_reg_grp_id reg_grp, 1641 + enum iqs7211_reg_key_id reg_key) 1642 + { 1643 + struct i2c_client *client = iqs7211->client; 1644 + int i; 1645 + 1646 + for (i = 0; i < ARRAY_SIZE(iqs7211_props); i++) { 1647 + const char *name = iqs7211_props[i].name; 1648 + u8 reg_addr = iqs7211_props[i].reg_addr[reg_grp] 1649 + [iqs7211->dev_desc - 1650 + iqs7211_devs]; 1651 + int reg_shift = iqs7211_props[i].reg_shift; 1652 + int reg_width = iqs7211_props[i].reg_width ? : 16; 1653 + int val_pitch = iqs7211_props[i].val_pitch ? : 1; 1654 + int val_min = iqs7211_props[i].val_min; 1655 + int val_max = iqs7211_props[i].val_max; 1656 + const char *label = iqs7211_props[i].label ? : name; 1657 + struct iqs7211_reg_field_desc reg_field; 1658 + unsigned int val; 1659 + int error; 1660 + 1661 + if (iqs7211_props[i].reg_key != reg_key) 1662 + continue; 1663 + 1664 + if (!reg_addr) 1665 + continue; 1666 + 1667 + error = fwnode_property_read_u32(reg_grp_node, name, &val); 1668 + if (error == -EINVAL) { 1669 + continue; 1670 + } else if (error) { 1671 + dev_err(&client->dev, "Failed to read %s %s: %d\n", 1672 + fwnode_get_name(reg_grp_node), label, error); 1673 + return error; 1674 + } 1675 + 1676 + if (!val_max) 1677 + val_max = GENMASK(reg_width - 1, 0) * val_pitch; 1678 + 1679 + if (val < val_min || val > val_max) { 1680 + dev_err(&client->dev, "Invalid %s: %u\n", label, val); 1681 + return -EINVAL; 1682 + } 1683 + 1684 + reg_field.addr = reg_addr; 1685 + reg_field.mask = GENMASK(reg_shift + reg_width - 1, reg_shift); 1686 + reg_field.val = val / val_pitch << reg_shift; 1687 + 1688 + error = iqs7211_add_field(iqs7211, reg_field); 1689 + if (error) 1690 + return error; 1691 + } 1692 + 1693 + return 0; 1694 + } 1695 + 1696 + static int iqs7211_parse_event(struct iqs7211_private *iqs7211, 1697 + struct fwnode_handle *event_node, 1698 + enum iqs7211_reg_grp_id reg_grp, 1699 + enum iqs7211_reg_key_id reg_key, 1700 + unsigned int *event_code) 1701 + { 1702 + const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; 1703 + struct i2c_client *client = iqs7211->client; 1704 + struct iqs7211_reg_field_desc reg_field; 1705 + unsigned int val; 1706 + int error; 1707 + 1708 + error = iqs7211_parse_props(iqs7211, event_node, reg_grp, reg_key); 1709 + if (error) 1710 + return error; 1711 + 1712 + if (reg_key == IQS7211_REG_KEY_AXIAL_X || 1713 + reg_key == IQS7211_REG_KEY_AXIAL_Y) { 1714 + error = fwnode_property_read_u32(event_node, 1715 + "azoteq,gesture-angle", &val); 1716 + if (!error) { 1717 + if (val >= ARRAY_SIZE(iqs7211_gesture_angle)) { 1718 + dev_err(&client->dev, 1719 + "Invalid %s gesture angle: %u\n", 1720 + fwnode_get_name(event_node), val); 1721 + return -EINVAL; 1722 + } 1723 + 1724 + reg_field.addr = dev_desc->gesture_angle; 1725 + reg_field.mask = U8_MAX; 1726 + reg_field.val = iqs7211_gesture_angle[val]; 1727 + 1728 + error = iqs7211_add_field(iqs7211, reg_field); 1729 + if (error) 1730 + return error; 1731 + } else if (error != -EINVAL) { 1732 + dev_err(&client->dev, 1733 + "Failed to read %s gesture angle: %d\n", 1734 + fwnode_get_name(event_node), error); 1735 + return error; 1736 + } 1737 + } 1738 + 1739 + error = fwnode_property_read_u32(event_node, "linux,code", event_code); 1740 + if (error == -EINVAL) 1741 + error = 0; 1742 + else if (error) 1743 + dev_err(&client->dev, "Failed to read %s code: %d\n", 1744 + fwnode_get_name(event_node), error); 1745 + 1746 + return error; 1747 + } 1748 + 1749 + static int iqs7211_parse_cycles(struct iqs7211_private *iqs7211, 1750 + struct fwnode_handle *tp_node) 1751 + { 1752 + const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; 1753 + struct i2c_client *client = iqs7211->client; 1754 + int num_cycles = dev_desc->cycle_limit[0] + dev_desc->cycle_limit[1]; 1755 + int error, count, i, j, k, cycle_start; 1756 + unsigned int cycle_alloc[IQS7211_MAX_CYCLES][2]; 1757 + u8 total_rx = iqs7211->tp_config.total_rx; 1758 + u8 total_tx = iqs7211->tp_config.total_tx; 1759 + 1760 + for (i = 0; i < IQS7211_MAX_CYCLES * 2; i++) 1761 + *(cycle_alloc[0] + i) = U8_MAX; 1762 + 1763 + count = fwnode_property_count_u32(tp_node, "azoteq,channel-select"); 1764 + if (count == -EINVAL) { 1765 + /* 1766 + * Assign each sensing cycle's slots (0 and 1) to a channel, 1767 + * defined as the intersection between two CRx and CTx pins. 1768 + * A channel assignment of 255 means the slot is unused. 1769 + */ 1770 + for (i = 0, cycle_start = 0; i < total_tx; i++) { 1771 + int cycle_stop = 0; 1772 + 1773 + for (j = 0; j < total_rx; j++) { 1774 + /* 1775 + * Channels formed by CRx0-3 and CRx4-7 are 1776 + * bound to slots 0 and 1, respectively. 1777 + */ 1778 + int slot = iqs7211->rx_tx_map[j] < 4 ? 0 : 1; 1779 + int chan = i * total_rx + j; 1780 + 1781 + for (k = cycle_start; k < num_cycles; k++) { 1782 + if (cycle_alloc[k][slot] < U8_MAX) 1783 + continue; 1784 + 1785 + cycle_alloc[k][slot] = chan; 1786 + break; 1787 + } 1788 + 1789 + if (k < num_cycles) { 1790 + cycle_stop = max(k, cycle_stop); 1791 + continue; 1792 + } 1793 + 1794 + dev_err(&client->dev, 1795 + "Insufficient number of cycles\n"); 1796 + return -EINVAL; 1797 + } 1798 + 1799 + /* 1800 + * Sensing cycles cannot straddle more than one CTx 1801 + * pin. As such, the next row's starting cycle must 1802 + * be greater than the previous row's highest cycle. 1803 + */ 1804 + cycle_start = cycle_stop + 1; 1805 + } 1806 + } else if (count < 0) { 1807 + dev_err(&client->dev, "Failed to count channels: %d\n", count); 1808 + return count; 1809 + } else if (count > num_cycles * 2) { 1810 + dev_err(&client->dev, "Insufficient number of cycles\n"); 1811 + return -EINVAL; 1812 + } else if (count > 0) { 1813 + error = fwnode_property_read_u32_array(tp_node, 1814 + "azoteq,channel-select", 1815 + cycle_alloc[0], count); 1816 + if (error) { 1817 + dev_err(&client->dev, "Failed to read channels: %d\n", 1818 + error); 1819 + return error; 1820 + } 1821 + 1822 + for (i = 0; i < count; i++) { 1823 + int chan = *(cycle_alloc[0] + i); 1824 + 1825 + if (chan == U8_MAX) 1826 + continue; 1827 + 1828 + if (chan >= total_rx * total_tx) { 1829 + dev_err(&client->dev, "Invalid channel: %d\n", 1830 + chan); 1831 + return -EINVAL; 1832 + } 1833 + 1834 + for (j = 0; j < count; j++) { 1835 + if (j == i || *(cycle_alloc[0] + j) != chan) 1836 + continue; 1837 + 1838 + dev_err(&client->dev, "Duplicate channel: %d\n", 1839 + chan); 1840 + return -EINVAL; 1841 + } 1842 + } 1843 + } 1844 + 1845 + /* 1846 + * Once the raw channel assignments have been derived, they must be 1847 + * packed according to the device's register map. 1848 + */ 1849 + for (i = 0, cycle_start = 0; i < sizeof(dev_desc->cycle_limit); i++) { 1850 + int offs = 0; 1851 + 1852 + for (j = cycle_start; 1853 + j < cycle_start + dev_desc->cycle_limit[i]; j++) { 1854 + iqs7211->cycle_alloc[i][offs++] = 0x05; 1855 + iqs7211->cycle_alloc[i][offs++] = cycle_alloc[j][0]; 1856 + iqs7211->cycle_alloc[i][offs++] = cycle_alloc[j][1]; 1857 + } 1858 + 1859 + cycle_start += dev_desc->cycle_limit[i]; 1860 + } 1861 + 1862 + return 0; 1863 + } 1864 + 1865 + static int iqs7211_parse_tp(struct iqs7211_private *iqs7211, 1866 + struct fwnode_handle *tp_node) 1867 + { 1868 + const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; 1869 + struct i2c_client *client = iqs7211->client; 1870 + unsigned int pins[IQS7211_MAX_CTX]; 1871 + int error, count, i, j; 1872 + 1873 + count = fwnode_property_count_u32(tp_node, "azoteq,rx-enable"); 1874 + if (count == -EINVAL) { 1875 + return 0; 1876 + } else if (count < 0) { 1877 + dev_err(&client->dev, "Failed to count CRx pins: %d\n", count); 1878 + return count; 1879 + } else if (count > IQS7211_NUM_CRX) { 1880 + dev_err(&client->dev, "Invalid number of CRx pins\n"); 1881 + return -EINVAL; 1882 + } 1883 + 1884 + error = fwnode_property_read_u32_array(tp_node, "azoteq,rx-enable", 1885 + pins, count); 1886 + if (error) { 1887 + dev_err(&client->dev, "Failed to read CRx pins: %d\n", error); 1888 + return error; 1889 + } 1890 + 1891 + for (i = 0; i < count; i++) { 1892 + if (pins[i] >= IQS7211_NUM_CRX) { 1893 + dev_err(&client->dev, "Invalid CRx pin: %u\n", pins[i]); 1894 + return -EINVAL; 1895 + } 1896 + 1897 + iqs7211->rx_tx_map[i] = pins[i]; 1898 + } 1899 + 1900 + iqs7211->tp_config.total_rx = count; 1901 + 1902 + count = fwnode_property_count_u32(tp_node, "azoteq,tx-enable"); 1903 + if (count < 0) { 1904 + dev_err(&client->dev, "Failed to count CTx pins: %d\n", count); 1905 + return count; 1906 + } else if (count > dev_desc->num_ctx) { 1907 + dev_err(&client->dev, "Invalid number of CTx pins\n"); 1908 + return -EINVAL; 1909 + } 1910 + 1911 + error = fwnode_property_read_u32_array(tp_node, "azoteq,tx-enable", 1912 + pins, count); 1913 + if (error) { 1914 + dev_err(&client->dev, "Failed to read CTx pins: %d\n", error); 1915 + return error; 1916 + } 1917 + 1918 + for (i = 0; i < count; i++) { 1919 + if (pins[i] >= dev_desc->num_ctx) { 1920 + dev_err(&client->dev, "Invalid CTx pin: %u\n", pins[i]); 1921 + return -EINVAL; 1922 + } 1923 + 1924 + for (j = 0; j < iqs7211->tp_config.total_rx; j++) { 1925 + if (iqs7211->rx_tx_map[j] != pins[i]) 1926 + continue; 1927 + 1928 + dev_err(&client->dev, "Conflicting CTx pin: %u\n", 1929 + pins[i]); 1930 + return -EINVAL; 1931 + } 1932 + 1933 + iqs7211->rx_tx_map[iqs7211->tp_config.total_rx + i] = pins[i]; 1934 + } 1935 + 1936 + iqs7211->tp_config.total_tx = count; 1937 + 1938 + return iqs7211_parse_cycles(iqs7211, tp_node); 1939 + } 1940 + 1941 + static int iqs7211_parse_alp(struct iqs7211_private *iqs7211, 1942 + struct fwnode_handle *alp_node) 1943 + { 1944 + const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; 1945 + struct i2c_client *client = iqs7211->client; 1946 + struct iqs7211_reg_field_desc reg_field; 1947 + int error, count, i; 1948 + 1949 + count = fwnode_property_count_u32(alp_node, "azoteq,rx-enable"); 1950 + if (count < 0 && count != -EINVAL) { 1951 + dev_err(&client->dev, "Failed to count CRx pins: %d\n", count); 1952 + return count; 1953 + } else if (count > IQS7211_NUM_CRX) { 1954 + dev_err(&client->dev, "Invalid number of CRx pins\n"); 1955 + return -EINVAL; 1956 + } else if (count >= 0) { 1957 + unsigned int pins[IQS7211_NUM_CRX]; 1958 + 1959 + error = fwnode_property_read_u32_array(alp_node, 1960 + "azoteq,rx-enable", 1961 + pins, count); 1962 + if (error) { 1963 + dev_err(&client->dev, "Failed to read CRx pins: %d\n", 1964 + error); 1965 + return error; 1966 + } 1967 + 1968 + reg_field.addr = dev_desc->alp_config; 1969 + reg_field.mask = GENMASK(IQS7211_NUM_CRX - 1, 0); 1970 + reg_field.val = 0; 1971 + 1972 + for (i = 0; i < count; i++) { 1973 + if (pins[i] < dev_desc->min_crx_alp || 1974 + pins[i] >= IQS7211_NUM_CRX) { 1975 + dev_err(&client->dev, "Invalid CRx pin: %u\n", 1976 + pins[i]); 1977 + return -EINVAL; 1978 + } 1979 + 1980 + reg_field.val |= BIT(pins[i]); 1981 + } 1982 + 1983 + error = iqs7211_add_field(iqs7211, reg_field); 1984 + if (error) 1985 + return error; 1986 + } 1987 + 1988 + count = fwnode_property_count_u32(alp_node, "azoteq,tx-enable"); 1989 + if (count < 0 && count != -EINVAL) { 1990 + dev_err(&client->dev, "Failed to count CTx pins: %d\n", count); 1991 + return count; 1992 + } else if (count > dev_desc->num_ctx) { 1993 + dev_err(&client->dev, "Invalid number of CTx pins\n"); 1994 + return -EINVAL; 1995 + } else if (count >= 0) { 1996 + unsigned int pins[IQS7211_MAX_CTX]; 1997 + 1998 + error = fwnode_property_read_u32_array(alp_node, 1999 + "azoteq,tx-enable", 2000 + pins, count); 2001 + if (error) { 2002 + dev_err(&client->dev, "Failed to read CTx pins: %d\n", 2003 + error); 2004 + return error; 2005 + } 2006 + 2007 + reg_field.addr = dev_desc->alp_config + 1; 2008 + reg_field.mask = GENMASK(dev_desc->num_ctx - 1, 0); 2009 + reg_field.val = 0; 2010 + 2011 + for (i = 0; i < count; i++) { 2012 + if (pins[i] >= dev_desc->num_ctx) { 2013 + dev_err(&client->dev, "Invalid CTx pin: %u\n", 2014 + pins[i]); 2015 + return -EINVAL; 2016 + } 2017 + 2018 + reg_field.val |= BIT(pins[i]); 2019 + } 2020 + 2021 + error = iqs7211_add_field(iqs7211, reg_field); 2022 + if (error) 2023 + return error; 2024 + } 2025 + 2026 + return 0; 2027 + } 2028 + 2029 + static int (*iqs7211_parse_extra[IQS7211_NUM_REG_GRPS]) 2030 + (struct iqs7211_private *iqs7211, 2031 + struct fwnode_handle *reg_grp_node) = { 2032 + [IQS7211_REG_GRP_TP] = iqs7211_parse_tp, 2033 + [IQS7211_REG_GRP_ALP] = iqs7211_parse_alp, 2034 + }; 2035 + 2036 + static int iqs7211_parse_reg_grp(struct iqs7211_private *iqs7211, 2037 + struct fwnode_handle *reg_grp_node, 2038 + enum iqs7211_reg_grp_id reg_grp) 2039 + { 2040 + const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; 2041 + struct iqs7211_reg_field_desc reg_field; 2042 + int error, i; 2043 + 2044 + error = iqs7211_parse_props(iqs7211, reg_grp_node, reg_grp, 2045 + IQS7211_REG_KEY_NONE); 2046 + if (error) 2047 + return error; 2048 + 2049 + if (iqs7211_parse_extra[reg_grp]) { 2050 + error = iqs7211_parse_extra[reg_grp](iqs7211, reg_grp_node); 2051 + if (error) 2052 + return error; 2053 + } 2054 + 2055 + iqs7211->ati_start |= dev_desc->ati_start[reg_grp]; 2056 + 2057 + reg_field.addr = dev_desc->kp_enable[reg_grp]; 2058 + reg_field.mask = 0; 2059 + reg_field.val = 0; 2060 + 2061 + for (i = 0; i < dev_desc->num_kp_events; i++) { 2062 + const char *event_name = dev_desc->kp_events[i].name; 2063 + struct fwnode_handle *event_node; 2064 + 2065 + if (dev_desc->kp_events[i].reg_grp != reg_grp) 2066 + continue; 2067 + 2068 + reg_field.mask |= dev_desc->kp_events[i].enable; 2069 + 2070 + if (event_name) 2071 + event_node = fwnode_get_named_child_node(reg_grp_node, 2072 + event_name); 2073 + else 2074 + event_node = fwnode_handle_get(reg_grp_node); 2075 + 2076 + if (!event_node) 2077 + continue; 2078 + 2079 + error = iqs7211_parse_event(iqs7211, event_node, 2080 + dev_desc->kp_events[i].reg_grp, 2081 + dev_desc->kp_events[i].reg_key, 2082 + &iqs7211->kp_code[i]); 2083 + fwnode_handle_put(event_node); 2084 + if (error) 2085 + return error; 2086 + 2087 + reg_field.val |= dev_desc->kp_events[i].enable; 2088 + 2089 + iqs7211->event_mask |= iqs7211_reg_grp_masks[reg_grp]; 2090 + } 2091 + 2092 + return iqs7211_add_field(iqs7211, reg_field); 2093 + } 2094 + 2095 + static int iqs7211_register_kp(struct iqs7211_private *iqs7211) 2096 + { 2097 + const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; 2098 + struct input_dev *kp_idev = iqs7211->kp_idev; 2099 + struct i2c_client *client = iqs7211->client; 2100 + int error, i; 2101 + 2102 + for (i = 0; i < dev_desc->num_kp_events; i++) 2103 + if (iqs7211->kp_code[i]) 2104 + break; 2105 + 2106 + if (i == dev_desc->num_kp_events) 2107 + return 0; 2108 + 2109 + kp_idev = devm_input_allocate_device(&client->dev); 2110 + if (!kp_idev) 2111 + return -ENOMEM; 2112 + 2113 + iqs7211->kp_idev = kp_idev; 2114 + 2115 + kp_idev->name = dev_desc->kp_name; 2116 + kp_idev->id.bustype = BUS_I2C; 2117 + 2118 + for (i = 0; i < dev_desc->num_kp_events; i++) 2119 + if (iqs7211->kp_code[i]) 2120 + input_set_capability(iqs7211->kp_idev, EV_KEY, 2121 + iqs7211->kp_code[i]); 2122 + 2123 + error = input_register_device(kp_idev); 2124 + if (error) 2125 + dev_err(&client->dev, "Failed to register %s: %d\n", 2126 + kp_idev->name, error); 2127 + 2128 + return error; 2129 + } 2130 + 2131 + static int iqs7211_register_tp(struct iqs7211_private *iqs7211) 2132 + { 2133 + const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; 2134 + struct touchscreen_properties *prop = &iqs7211->prop; 2135 + struct input_dev *tp_idev = iqs7211->tp_idev; 2136 + struct i2c_client *client = iqs7211->client; 2137 + int error; 2138 + 2139 + error = device_property_read_u32(&client->dev, "azoteq,num-contacts", 2140 + &iqs7211->num_contacts); 2141 + if (error == -EINVAL) { 2142 + return 0; 2143 + } else if (error) { 2144 + dev_err(&client->dev, "Failed to read number of contacts: %d\n", 2145 + error); 2146 + return error; 2147 + } else if (iqs7211->num_contacts > IQS7211_MAX_CONTACTS) { 2148 + dev_err(&client->dev, "Invalid number of contacts: %u\n", 2149 + iqs7211->num_contacts); 2150 + return -EINVAL; 2151 + } 2152 + 2153 + iqs7211->tp_config.num_contacts = iqs7211->num_contacts ? : 1; 2154 + 2155 + if (!iqs7211->num_contacts) 2156 + return 0; 2157 + 2158 + iqs7211->event_mask |= IQS7211_EVENT_MASK_MOVE; 2159 + 2160 + tp_idev = devm_input_allocate_device(&client->dev); 2161 + if (!tp_idev) 2162 + return -ENOMEM; 2163 + 2164 + iqs7211->tp_idev = tp_idev; 2165 + 2166 + tp_idev->name = dev_desc->tp_name; 2167 + tp_idev->id.bustype = BUS_I2C; 2168 + 2169 + input_set_abs_params(tp_idev, ABS_MT_POSITION_X, 2170 + 0, le16_to_cpu(iqs7211->tp_config.max_x), 0, 0); 2171 + 2172 + input_set_abs_params(tp_idev, ABS_MT_POSITION_Y, 2173 + 0, le16_to_cpu(iqs7211->tp_config.max_y), 0, 0); 2174 + 2175 + input_set_abs_params(tp_idev, ABS_MT_PRESSURE, 0, U16_MAX, 0, 0); 2176 + 2177 + touchscreen_parse_properties(tp_idev, true, prop); 2178 + 2179 + /* 2180 + * The device reserves 0xFFFF for coordinates that correspond to slots 2181 + * which are not in a state of touch. 2182 + */ 2183 + if (prop->max_x >= U16_MAX || prop->max_y >= U16_MAX) { 2184 + dev_err(&client->dev, "Invalid trackpad size: %u*%u\n", 2185 + prop->max_x, prop->max_y); 2186 + return -EINVAL; 2187 + } 2188 + 2189 + iqs7211->tp_config.max_x = cpu_to_le16(prop->max_x); 2190 + iqs7211->tp_config.max_y = cpu_to_le16(prop->max_y); 2191 + 2192 + error = input_mt_init_slots(tp_idev, iqs7211->num_contacts, 2193 + INPUT_MT_DIRECT); 2194 + if (error) { 2195 + dev_err(&client->dev, "Failed to initialize slots: %d\n", 2196 + error); 2197 + return error; 2198 + } 2199 + 2200 + error = input_register_device(tp_idev); 2201 + if (error) 2202 + dev_err(&client->dev, "Failed to register %s: %d\n", 2203 + tp_idev->name, error); 2204 + 2205 + return error; 2206 + } 2207 + 2208 + static int iqs7211_report(struct iqs7211_private *iqs7211) 2209 + { 2210 + const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; 2211 + struct i2c_client *client = iqs7211->client; 2212 + struct iqs7211_touch_data *touch_data; 2213 + u16 info_flags, charge_mode, gesture_flags; 2214 + __le16 status[12]; 2215 + int error, i; 2216 + 2217 + error = iqs7211_read_burst(iqs7211, dev_desc->sys_stat, status, 2218 + dev_desc->contact_offs * sizeof(__le16) + 2219 + iqs7211->num_contacts * sizeof(*touch_data)); 2220 + if (error) 2221 + return error; 2222 + 2223 + info_flags = le16_to_cpu(status[dev_desc->info_offs]); 2224 + 2225 + if (info_flags & dev_desc->show_reset) { 2226 + dev_err(&client->dev, "Unexpected device reset\n"); 2227 + 2228 + /* 2229 + * The device may or may not expect forced communication after 2230 + * it exits hardware reset, so the corresponding state machine 2231 + * must be reset as well. 2232 + */ 2233 + iqs7211->comms_mode = iqs7211->comms_init; 2234 + 2235 + return iqs7211_init_device(iqs7211); 2236 + } 2237 + 2238 + for (i = 0; i < ARRAY_SIZE(dev_desc->ati_error); i++) { 2239 + if (!(info_flags & dev_desc->ati_error[i])) 2240 + continue; 2241 + 2242 + dev_err(&client->dev, "Unexpected %s ATI error\n", 2243 + iqs7211_reg_grp_names[i]); 2244 + return 0; 2245 + } 2246 + 2247 + for (i = 0; i < iqs7211->num_contacts; i++) { 2248 + u16 pressure; 2249 + 2250 + touch_data = (struct iqs7211_touch_data *) 2251 + &status[dev_desc->contact_offs] + i; 2252 + pressure = le16_to_cpu(touch_data->pressure); 2253 + 2254 + input_mt_slot(iqs7211->tp_idev, i); 2255 + if (input_mt_report_slot_state(iqs7211->tp_idev, MT_TOOL_FINGER, 2256 + pressure != 0)) { 2257 + touchscreen_report_pos(iqs7211->tp_idev, &iqs7211->prop, 2258 + le16_to_cpu(touch_data->abs_x), 2259 + le16_to_cpu(touch_data->abs_y), 2260 + true); 2261 + input_report_abs(iqs7211->tp_idev, ABS_MT_PRESSURE, 2262 + pressure); 2263 + } 2264 + } 2265 + 2266 + if (iqs7211->num_contacts) { 2267 + input_mt_sync_frame(iqs7211->tp_idev); 2268 + input_sync(iqs7211->tp_idev); 2269 + } 2270 + 2271 + if (!iqs7211->kp_idev) 2272 + return 0; 2273 + 2274 + charge_mode = info_flags & GENMASK(dev_desc->charge_shift + 2, 2275 + dev_desc->charge_shift); 2276 + charge_mode >>= dev_desc->charge_shift; 2277 + 2278 + /* 2279 + * A charging mode higher than 2 (idle mode) indicates the device last 2280 + * operated in low-power mode and intends to express an ALP event. 2281 + */ 2282 + if (info_flags & dev_desc->kp_events->mask && charge_mode > 2) { 2283 + input_report_key(iqs7211->kp_idev, *iqs7211->kp_code, 1); 2284 + input_sync(iqs7211->kp_idev); 2285 + 2286 + input_report_key(iqs7211->kp_idev, *iqs7211->kp_code, 0); 2287 + } 2288 + 2289 + for (i = 0; i < dev_desc->num_kp_events; i++) { 2290 + if (dev_desc->kp_events[i].reg_grp != IQS7211_REG_GRP_BTN) 2291 + continue; 2292 + 2293 + input_report_key(iqs7211->kp_idev, iqs7211->kp_code[i], 2294 + info_flags & dev_desc->kp_events[i].mask); 2295 + } 2296 + 2297 + gesture_flags = le16_to_cpu(status[dev_desc->gesture_offs]); 2298 + 2299 + for (i = 0; i < dev_desc->num_kp_events; i++) { 2300 + enum iqs7211_reg_key_id reg_key = dev_desc->kp_events[i].reg_key; 2301 + u16 mask = dev_desc->kp_events[i].mask; 2302 + 2303 + if (dev_desc->kp_events[i].reg_grp != IQS7211_REG_GRP_TP) 2304 + continue; 2305 + 2306 + if ((gesture_flags ^ iqs7211->gesture_cache) & mask) 2307 + input_report_key(iqs7211->kp_idev, iqs7211->kp_code[i], 2308 + gesture_flags & mask); 2309 + 2310 + iqs7211->gesture_cache &= ~mask; 2311 + 2312 + /* 2313 + * Hold and palm gestures persist while the contact remains in 2314 + * place; all others are momentary and hence are followed by a 2315 + * complementary release event. 2316 + */ 2317 + if (reg_key == IQS7211_REG_KEY_HOLD || 2318 + reg_key == IQS7211_REG_KEY_PALM) { 2319 + iqs7211->gesture_cache |= gesture_flags & mask; 2320 + gesture_flags &= ~mask; 2321 + } 2322 + } 2323 + 2324 + if (gesture_flags) { 2325 + input_sync(iqs7211->kp_idev); 2326 + 2327 + for (i = 0; i < dev_desc->num_kp_events; i++) 2328 + if (dev_desc->kp_events[i].reg_grp == IQS7211_REG_GRP_TP && 2329 + gesture_flags & dev_desc->kp_events[i].mask) 2330 + input_report_key(iqs7211->kp_idev, 2331 + iqs7211->kp_code[i], 0); 2332 + } 2333 + 2334 + input_sync(iqs7211->kp_idev); 2335 + 2336 + return 0; 2337 + } 2338 + 2339 + static irqreturn_t iqs7211_irq(int irq, void *context) 2340 + { 2341 + struct iqs7211_private *iqs7211 = context; 2342 + 2343 + return iqs7211_report(iqs7211) ? IRQ_NONE : IRQ_HANDLED; 2344 + } 2345 + 2346 + static int iqs7211_suspend(struct device *dev) 2347 + { 2348 + struct iqs7211_private *iqs7211 = dev_get_drvdata(dev); 2349 + const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; 2350 + int error; 2351 + 2352 + if (!dev_desc->suspend || device_may_wakeup(dev)) 2353 + return 0; 2354 + 2355 + /* 2356 + * I2C communication prompts the device to assert its RDY pin if it is 2357 + * not already asserted. As such, the interrupt must be disabled so as 2358 + * to prevent reentrant interrupts. 2359 + */ 2360 + disable_irq(gpiod_to_irq(iqs7211->irq_gpio)); 2361 + 2362 + error = iqs7211_write_word(iqs7211, dev_desc->sys_ctrl, 2363 + dev_desc->suspend); 2364 + 2365 + enable_irq(gpiod_to_irq(iqs7211->irq_gpio)); 2366 + 2367 + return error; 2368 + } 2369 + 2370 + static int iqs7211_resume(struct device *dev) 2371 + { 2372 + struct iqs7211_private *iqs7211 = dev_get_drvdata(dev); 2373 + const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; 2374 + __le16 sys_ctrl[] = { 2375 + 0, 2376 + cpu_to_le16(iqs7211->event_mask), 2377 + }; 2378 + int error; 2379 + 2380 + if (!dev_desc->suspend || device_may_wakeup(dev)) 2381 + return 0; 2382 + 2383 + disable_irq(gpiod_to_irq(iqs7211->irq_gpio)); 2384 + 2385 + /* 2386 + * Forced communication, if in use, must be explicitly enabled as part 2387 + * of the wake-up command. 2388 + */ 2389 + error = iqs7211_write_burst(iqs7211, dev_desc->sys_ctrl, sys_ctrl, 2390 + sizeof(sys_ctrl)); 2391 + 2392 + enable_irq(gpiod_to_irq(iqs7211->irq_gpio)); 2393 + 2394 + return error; 2395 + } 2396 + 2397 + static DEFINE_SIMPLE_DEV_PM_OPS(iqs7211_pm, iqs7211_suspend, iqs7211_resume); 2398 + 2399 + static ssize_t fw_info_show(struct device *dev, 2400 + struct device_attribute *attr, char *buf) 2401 + { 2402 + struct iqs7211_private *iqs7211 = dev_get_drvdata(dev); 2403 + 2404 + return scnprintf(buf, PAGE_SIZE, "%u.%u.%u.%u:%u.%u\n", 2405 + le16_to_cpu(iqs7211->ver_info.prod_num), 2406 + le32_to_cpu(iqs7211->ver_info.patch), 2407 + le16_to_cpu(iqs7211->ver_info.major), 2408 + le16_to_cpu(iqs7211->ver_info.minor), 2409 + iqs7211->exp_file[1], iqs7211->exp_file[0]); 2410 + } 2411 + 2412 + static DEVICE_ATTR_RO(fw_info); 2413 + 2414 + static struct attribute *iqs7211_attrs[] = { 2415 + &dev_attr_fw_info.attr, 2416 + NULL 2417 + }; 2418 + ATTRIBUTE_GROUPS(iqs7211); 2419 + 2420 + static const struct of_device_id iqs7211_of_match[] = { 2421 + { 2422 + .compatible = "azoteq,iqs7210a", 2423 + .data = &iqs7211_devs[IQS7210A], 2424 + }, 2425 + { 2426 + .compatible = "azoteq,iqs7211a", 2427 + .data = &iqs7211_devs[IQS7211A], 2428 + }, 2429 + { 2430 + .compatible = "azoteq,iqs7211e", 2431 + .data = &iqs7211_devs[IQS7211E], 2432 + }, 2433 + { } 2434 + }; 2435 + MODULE_DEVICE_TABLE(of, iqs7211_of_match); 2436 + 2437 + static int iqs7211_probe(struct i2c_client *client) 2438 + { 2439 + struct iqs7211_private *iqs7211; 2440 + enum iqs7211_reg_grp_id reg_grp; 2441 + unsigned long irq_flags; 2442 + bool shared_irq; 2443 + int error, irq; 2444 + 2445 + iqs7211 = devm_kzalloc(&client->dev, sizeof(*iqs7211), GFP_KERNEL); 2446 + if (!iqs7211) 2447 + return -ENOMEM; 2448 + 2449 + i2c_set_clientdata(client, iqs7211); 2450 + iqs7211->client = client; 2451 + 2452 + INIT_LIST_HEAD(&iqs7211->reg_field_head); 2453 + 2454 + iqs7211->dev_desc = device_get_match_data(&client->dev); 2455 + if (!iqs7211->dev_desc) 2456 + return -ENODEV; 2457 + 2458 + shared_irq = iqs7211->dev_desc->num_ctx == IQS7211_MAX_CTX; 2459 + 2460 + /* 2461 + * The RDY pin behaves as an interrupt, but must also be polled ahead 2462 + * of unsolicited I2C communication. As such, it is first opened as a 2463 + * GPIO and then passed to gpiod_to_irq() to register the interrupt. 2464 + * 2465 + * If an extra CTx pin is present, the RDY and MCLR pins are combined 2466 + * into a single bidirectional pin. In that case, the platform's GPIO 2467 + * must be configured as an open-drain output. 2468 + */ 2469 + iqs7211->irq_gpio = devm_gpiod_get(&client->dev, "irq", 2470 + shared_irq ? GPIOD_OUT_LOW 2471 + : GPIOD_IN); 2472 + if (IS_ERR(iqs7211->irq_gpio)) { 2473 + error = PTR_ERR(iqs7211->irq_gpio); 2474 + dev_err(&client->dev, "Failed to request IRQ GPIO: %d\n", 2475 + error); 2476 + return error; 2477 + } 2478 + 2479 + if (shared_irq) { 2480 + iqs7211->reset_gpio = iqs7211->irq_gpio; 2481 + } else { 2482 + iqs7211->reset_gpio = devm_gpiod_get_optional(&client->dev, 2483 + "reset", 2484 + GPIOD_OUT_HIGH); 2485 + if (IS_ERR(iqs7211->reset_gpio)) { 2486 + error = PTR_ERR(iqs7211->reset_gpio); 2487 + dev_err(&client->dev, 2488 + "Failed to request reset GPIO: %d\n", error); 2489 + return error; 2490 + } 2491 + } 2492 + 2493 + error = iqs7211_start_comms(iqs7211); 2494 + if (error) 2495 + return error; 2496 + 2497 + for (reg_grp = 0; reg_grp < IQS7211_NUM_REG_GRPS; reg_grp++) { 2498 + const char *reg_grp_name = iqs7211_reg_grp_names[reg_grp]; 2499 + struct fwnode_handle *reg_grp_node; 2500 + 2501 + if (reg_grp_name) 2502 + reg_grp_node = device_get_named_child_node(&client->dev, 2503 + reg_grp_name); 2504 + else 2505 + reg_grp_node = fwnode_handle_get(dev_fwnode(&client->dev)); 2506 + 2507 + if (!reg_grp_node) 2508 + continue; 2509 + 2510 + error = iqs7211_parse_reg_grp(iqs7211, reg_grp_node, reg_grp); 2511 + fwnode_handle_put(reg_grp_node); 2512 + if (error) 2513 + return error; 2514 + } 2515 + 2516 + error = iqs7211_register_kp(iqs7211); 2517 + if (error) 2518 + return error; 2519 + 2520 + error = iqs7211_register_tp(iqs7211); 2521 + if (error) 2522 + return error; 2523 + 2524 + error = iqs7211_init_device(iqs7211); 2525 + if (error) 2526 + return error; 2527 + 2528 + irq = gpiod_to_irq(iqs7211->irq_gpio); 2529 + if (irq < 0) 2530 + return irq; 2531 + 2532 + irq_flags = gpiod_is_active_low(iqs7211->irq_gpio) ? IRQF_TRIGGER_LOW 2533 + : IRQF_TRIGGER_HIGH; 2534 + irq_flags |= IRQF_ONESHOT; 2535 + 2536 + error = devm_request_threaded_irq(&client->dev, irq, NULL, iqs7211_irq, 2537 + irq_flags, client->name, iqs7211); 2538 + if (error) 2539 + dev_err(&client->dev, "Failed to request IRQ: %d\n", error); 2540 + 2541 + return error; 2542 + } 2543 + 2544 + static struct i2c_driver iqs7211_i2c_driver = { 2545 + .probe = iqs7211_probe, 2546 + .driver = { 2547 + .name = "iqs7211", 2548 + .of_match_table = iqs7211_of_match, 2549 + .dev_groups = iqs7211_groups, 2550 + .pm = pm_sleep_ptr(&iqs7211_pm), 2551 + }, 2552 + }; 2553 + module_i2c_driver(iqs7211_i2c_driver); 2554 + 2555 + MODULE_AUTHOR("Jeff LaBundy <jeff@labundy.com>"); 2556 + MODULE_DESCRIPTION("Azoteq IQS7210A/7211A/E Trackpad/Touchscreen Controller"); 2557 + MODULE_LICENSE("GPL");
+22 -76
drivers/input/touchscreen/lpc32xx_ts.c
··· 198 198 199 199 static int lpc32xx_ts_probe(struct platform_device *pdev) 200 200 { 201 + struct device *dev = &pdev->dev; 201 202 struct lpc32xx_tsc *tsc; 202 203 struct input_dev *input; 203 - struct resource *res; 204 - resource_size_t size; 205 204 int irq; 206 205 int error; 207 - 208 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 209 - if (!res) { 210 - dev_err(&pdev->dev, "Can't get memory resource\n"); 211 - return -ENOENT; 212 - } 213 206 214 207 irq = platform_get_irq(pdev, 0); 215 208 if (irq < 0) 216 209 return irq; 217 210 218 - tsc = kzalloc(sizeof(*tsc), GFP_KERNEL); 219 - input = input_allocate_device(); 220 - if (!tsc || !input) { 221 - dev_err(&pdev->dev, "failed allocating memory\n"); 222 - error = -ENOMEM; 223 - goto err_free_mem; 224 - } 211 + tsc = devm_kzalloc(dev, sizeof(*tsc), GFP_KERNEL); 212 + if (!tsc) 213 + return -ENOMEM; 225 214 226 - tsc->dev = input; 227 215 tsc->irq = irq; 228 216 229 - size = resource_size(res); 217 + tsc->tsc_base = devm_platform_ioremap_resource(pdev, 0); 218 + if (IS_ERR(tsc->tsc_base)) 219 + return PTR_ERR(tsc->tsc_base); 230 220 231 - if (!request_mem_region(res->start, size, pdev->name)) { 232 - dev_err(&pdev->dev, "TSC registers are not free\n"); 233 - error = -EBUSY; 234 - goto err_free_mem; 235 - } 236 - 237 - tsc->tsc_base = ioremap(res->start, size); 238 - if (!tsc->tsc_base) { 239 - dev_err(&pdev->dev, "Can't map memory\n"); 240 - error = -ENOMEM; 241 - goto err_release_mem; 242 - } 243 - 244 - tsc->clk = clk_get(&pdev->dev, NULL); 221 + tsc->clk = devm_clk_get(dev, NULL); 245 222 if (IS_ERR(tsc->clk)) { 246 223 dev_err(&pdev->dev, "failed getting clock\n"); 247 - error = PTR_ERR(tsc->clk); 248 - goto err_unmap; 224 + return PTR_ERR(tsc->clk); 225 + } 226 + 227 + input = devm_input_allocate_device(dev); 228 + if (!input) { 229 + dev_err(&pdev->dev, "failed allocating input device\n"); 230 + return -ENOMEM; 249 231 } 250 232 251 233 input->name = MOD_NAME; ··· 236 254 input->id.vendor = 0x0001; 237 255 input->id.product = 0x0002; 238 256 input->id.version = 0x0100; 239 - input->dev.parent = &pdev->dev; 240 257 input->open = lpc32xx_ts_open; 241 258 input->close = lpc32xx_ts_close; 242 259 243 - input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 244 - input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); 260 + input_set_capability(input, EV_KEY, BTN_TOUCH); 245 261 input_set_abs_params(input, ABS_X, LPC32XX_TSC_MIN_XY_VAL, 246 262 LPC32XX_TSC_MAX_XY_VAL, 0, 0); 247 263 input_set_abs_params(input, ABS_Y, LPC32XX_TSC_MIN_XY_VAL, 248 264 LPC32XX_TSC_MAX_XY_VAL, 0, 0); 249 265 250 266 input_set_drvdata(input, tsc); 267 + tsc->dev = input; 251 268 252 - error = request_irq(tsc->irq, lpc32xx_ts_interrupt, 253 - 0, pdev->name, tsc); 269 + error = devm_request_irq(dev, tsc->irq, lpc32xx_ts_interrupt, 270 + 0, pdev->name, tsc); 254 271 if (error) { 255 272 dev_err(&pdev->dev, "failed requesting interrupt\n"); 256 - goto err_put_clock; 273 + return error; 257 274 } 258 275 259 276 error = input_register_device(input); 260 277 if (error) { 261 278 dev_err(&pdev->dev, "failed registering input device\n"); 262 - goto err_free_irq; 279 + return error; 263 280 } 264 281 265 282 platform_set_drvdata(pdev, tsc); 266 - device_init_wakeup(&pdev->dev, 1); 267 - 268 - return 0; 269 - 270 - err_free_irq: 271 - free_irq(tsc->irq, tsc); 272 - err_put_clock: 273 - clk_put(tsc->clk); 274 - err_unmap: 275 - iounmap(tsc->tsc_base); 276 - err_release_mem: 277 - release_mem_region(res->start, size); 278 - err_free_mem: 279 - input_free_device(input); 280 - kfree(tsc); 281 - 282 - return error; 283 - } 284 - 285 - static int lpc32xx_ts_remove(struct platform_device *pdev) 286 - { 287 - struct lpc32xx_tsc *tsc = platform_get_drvdata(pdev); 288 - struct resource *res; 289 - 290 - free_irq(tsc->irq, tsc); 291 - 292 - input_unregister_device(tsc->dev); 293 - 294 - clk_put(tsc->clk); 295 - 296 - iounmap(tsc->tsc_base); 297 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 298 - release_mem_region(res->start, resource_size(res)); 299 - 300 - kfree(tsc); 283 + device_init_wakeup(&pdev->dev, true); 301 284 302 285 return 0; 303 286 } ··· 331 384 332 385 static struct platform_driver lpc32xx_ts_driver = { 333 386 .probe = lpc32xx_ts_probe, 334 - .remove = lpc32xx_ts_remove, 335 387 .driver = { 336 388 .name = MOD_NAME, 337 389 .pm = LPC32XX_TS_PM_OPS,
+2 -7
drivers/input/touchscreen/melfas_mip4.c
··· 1451 1451 1452 1452 ts->gpio_ce = devm_gpiod_get_optional(&client->dev, 1453 1453 "ce", GPIOD_OUT_LOW); 1454 - if (IS_ERR(ts->gpio_ce)) { 1455 - error = PTR_ERR(ts->gpio_ce); 1456 - if (error != -EPROBE_DEFER) 1457 - dev_err(&client->dev, 1458 - "Failed to get gpio: %d\n", error); 1459 - return error; 1460 - } 1454 + if (IS_ERR(ts->gpio_ce)) 1455 + return dev_err_probe(&client->dev, PTR_ERR(ts->gpio_ce), "Failed to get gpio\n"); 1461 1456 1462 1457 error = mip4_power_on(ts); 1463 1458 if (error)
+81 -8
drivers/input/touchscreen/mms114.c
··· 7 7 #include <linux/module.h> 8 8 #include <linux/delay.h> 9 9 #include <linux/of.h> 10 - #include <linux/of_device.h> 11 10 #include <linux/i2c.h> 12 11 #include <linux/input/mt.h> 13 12 #include <linux/input/touchscreen.h> ··· 42 43 /* Touchscreen absolute values */ 43 44 #define MMS114_MAX_AREA 0xff 44 45 46 + #define MMS114_MAX_TOUCHKEYS 15 45 47 #define MMS114_MAX_TOUCH 10 46 48 #define MMS114_EVENT_SIZE 8 47 49 #define MMS136_EVENT_SIZE 6 ··· 69 69 enum mms_type type; 70 70 unsigned int contact_threshold; 71 71 unsigned int moving_threshold; 72 + 73 + u32 keycodes[MMS114_MAX_TOUCHKEYS]; 74 + int num_keycodes; 72 75 73 76 /* Use cache data for mode control register(write only) */ 74 77 u8 cache_mode_control; ··· 170 167 return; 171 168 } 172 169 173 - if (touch->type != MMS114_TYPE_TOUCHSCREEN) { 174 - dev_err(&client->dev, "Wrong touch type (%d)\n", touch->type); 175 - return; 176 - } 177 - 178 170 id = touch->id - 1; 179 171 x = touch->x_lo | touch->x_hi << 8; 180 172 y = touch->y_lo | touch->y_hi << 8; ··· 189 191 } 190 192 } 191 193 194 + static void mms114_process_touchkey(struct mms114_data *data, 195 + struct mms114_touch *touch) 196 + { 197 + struct i2c_client *client = data->client; 198 + struct input_dev *input_dev = data->input_dev; 199 + unsigned int keycode_id; 200 + 201 + if (touch->id == 0) 202 + return; 203 + 204 + if (touch->id > data->num_keycodes) { 205 + dev_err(&client->dev, "Wrong touch id for touchkey (%d)\n", 206 + touch->id); 207 + return; 208 + } 209 + 210 + keycode_id = touch->id - 1; 211 + dev_dbg(&client->dev, "keycode id: %d, pressed: %d\n", keycode_id, 212 + touch->pressed); 213 + 214 + input_report_key(input_dev, data->keycodes[keycode_id], touch->pressed); 215 + } 216 + 192 217 static irqreturn_t mms114_interrupt(int irq, void *dev_id) 193 218 { 194 219 struct mms114_data *data = dev_id; 220 + struct i2c_client *client = data->client; 195 221 struct input_dev *input_dev = data->input_dev; 196 222 struct mms114_touch touch[MMS114_MAX_TOUCH]; 197 223 int packet_size; ··· 245 223 if (error < 0) 246 224 goto out; 247 225 248 - for (index = 0; index < touch_size; index++) 249 - mms114_process_mt(data, touch + index); 226 + for (index = 0; index < touch_size; index++) { 227 + switch (touch[index].type) { 228 + case MMS114_TYPE_TOUCHSCREEN: 229 + mms114_process_mt(data, touch + index); 230 + break; 231 + 232 + case MMS114_TYPE_TOUCHKEY: 233 + mms114_process_touchkey(data, touch + index); 234 + break; 235 + 236 + default: 237 + dev_err(&client->dev, "Wrong touch type (%d)\n", 238 + touch[index].type); 239 + break; 240 + } 241 + } 250 242 251 243 input_mt_report_pointer_emulation(data->input_dev, true); 252 244 input_sync(data->input_dev); ··· 482 446 struct input_dev *input_dev; 483 447 const void *match_data; 484 448 int error; 449 + int i; 485 450 486 451 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { 487 452 dev_err(&client->dev, "Not supported I2C adapter\n"); ··· 505 468 return -EINVAL; 506 469 507 470 data->type = (enum mms_type)match_data; 471 + 472 + data->num_keycodes = device_property_count_u32(&client->dev, 473 + "linux,keycodes"); 474 + if (data->num_keycodes == -EINVAL) { 475 + data->num_keycodes = 0; 476 + } else if (data->num_keycodes < 0) { 477 + dev_err(&client->dev, 478 + "Unable to parse linux,keycodes property: %d\n", 479 + data->num_keycodes); 480 + return data->num_keycodes; 481 + } else if (data->num_keycodes > MMS114_MAX_TOUCHKEYS) { 482 + dev_warn(&client->dev, 483 + "Found %d linux,keycodes but max is %d, ignoring the rest\n", 484 + data->num_keycodes, MMS114_MAX_TOUCHKEYS); 485 + data->num_keycodes = MMS114_MAX_TOUCHKEYS; 486 + } 487 + 488 + if (data->num_keycodes > 0) { 489 + error = device_property_read_u32_array(&client->dev, 490 + "linux,keycodes", 491 + data->keycodes, 492 + data->num_keycodes); 493 + if (error) { 494 + dev_err(&client->dev, 495 + "Unable to read linux,keycodes values: %d\n", 496 + error); 497 + return error; 498 + } 499 + 500 + input_dev->keycode = data->keycodes; 501 + input_dev->keycodemax = data->num_keycodes; 502 + input_dev->keycodesize = sizeof(data->keycodes[0]); 503 + for (i = 0; i < data->num_keycodes; i++) 504 + input_set_capability(input_dev, 505 + EV_KEY, data->keycodes[i]); 506 + } 508 507 509 508 input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_X); 510 509 input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_Y);
+4 -6
drivers/input/touchscreen/novatek-nvt-ts.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-or-later 2 2 /* 3 - * Driver for Novatek i2c touchscreen controller as found on 4 - * the Acer Iconia One 7 B1-750 tablet. The Touchscreen controller 5 - * model-number is unknown. Android calls this a "NVT-ts" touchscreen, 6 - * but that may apply to other Novatek controller models too. 3 + * Driver for Novatek NT11205 i2c touchscreen controller as found 4 + * on the Acer Iconia One 7 B1-750 tablet. 7 5 * 8 6 * Copyright (c) 2023 Hans de Goede <hdegoede@redhat.com> 9 7 */ ··· 270 272 271 273 error = input_register_device(input); 272 274 if (error) { 273 - dev_err(dev, "failed to request irq: %d\n", error); 275 + dev_err(dev, "failed to register input device: %d\n", error); 274 276 return error; 275 277 } 276 278 ··· 294 296 295 297 module_i2c_driver(nvt_ts_driver); 296 298 297 - MODULE_DESCRIPTION("Novatek NVT-ts touchscreen driver"); 299 + MODULE_DESCRIPTION("Novatek NT11205 touchscreen driver"); 298 300 MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>"); 299 301 MODULE_LICENSE("GPL");
+13 -27
drivers/input/touchscreen/pixcir_i2c_ts.c
··· 13 13 #include <linux/input/mt.h> 14 14 #include <linux/input/touchscreen.h> 15 15 #include <linux/interrupt.h> 16 - #include <linux/of_device.h> 17 16 #include <linux/module.h> 17 + #include <linux/of.h> 18 18 #include <linux/slab.h> 19 19 20 20 #define PIXCIR_MAX_SLOTS 5 /* Max fingers supported by driver */ ··· 515 515 input_set_drvdata(input, tsdata); 516 516 517 517 tsdata->gpio_attb = devm_gpiod_get(dev, "attb", GPIOD_IN); 518 - if (IS_ERR(tsdata->gpio_attb)) { 519 - error = PTR_ERR(tsdata->gpio_attb); 520 - if (error != -EPROBE_DEFER) 521 - dev_err(dev, "Failed to request ATTB gpio: %d\n", 522 - error); 523 - return error; 524 - } 518 + if (IS_ERR(tsdata->gpio_attb)) 519 + return dev_err_probe(dev, PTR_ERR(tsdata->gpio_attb), 520 + "Failed to request ATTB gpio\n"); 525 521 526 522 tsdata->gpio_reset = devm_gpiod_get_optional(dev, "reset", 527 523 GPIOD_OUT_LOW); 528 - if (IS_ERR(tsdata->gpio_reset)) { 529 - error = PTR_ERR(tsdata->gpio_reset); 530 - if (error != -EPROBE_DEFER) 531 - dev_err(dev, "Failed to request RESET gpio: %d\n", 532 - error); 533 - return error; 534 - } 524 + if (IS_ERR(tsdata->gpio_reset)) 525 + return dev_err_probe(dev, PTR_ERR(tsdata->gpio_reset), 526 + "Failed to request RESET gpio\n"); 535 527 536 528 tsdata->gpio_wake = devm_gpiod_get_optional(dev, "wake", 537 529 GPIOD_OUT_HIGH); 538 - if (IS_ERR(tsdata->gpio_wake)) { 539 - error = PTR_ERR(tsdata->gpio_wake); 540 - if (error != -EPROBE_DEFER) 541 - dev_err(dev, "Failed to get wake gpio: %d\n", error); 542 - return error; 543 - } 530 + if (IS_ERR(tsdata->gpio_wake)) 531 + return dev_err_probe(dev, PTR_ERR(tsdata->gpio_wake), 532 + "Failed to get wake gpio\n"); 544 533 545 534 tsdata->gpio_enable = devm_gpiod_get_optional(dev, "enable", 546 535 GPIOD_OUT_HIGH); 547 - if (IS_ERR(tsdata->gpio_enable)) { 548 - error = PTR_ERR(tsdata->gpio_enable); 549 - if (error != -EPROBE_DEFER) 550 - dev_err(dev, "Failed to get enable gpio: %d\n", error); 551 - return error; 552 - } 536 + if (IS_ERR(tsdata->gpio_enable)) 537 + return dev_err_probe(dev, PTR_ERR(tsdata->gpio_enable), 538 + "Failed to get enable gpio\n"); 553 539 554 540 if (tsdata->gpio_enable) 555 541 msleep(100);
+9 -21
drivers/input/touchscreen/raydium_i2c_ts.c
··· 1087 1087 i2c_set_clientdata(client, ts); 1088 1088 1089 1089 ts->avdd = devm_regulator_get(&client->dev, "avdd"); 1090 - if (IS_ERR(ts->avdd)) { 1091 - error = PTR_ERR(ts->avdd); 1092 - if (error != -EPROBE_DEFER) 1093 - dev_err(&client->dev, 1094 - "Failed to get 'avdd' regulator: %d\n", error); 1095 - return error; 1096 - } 1090 + if (IS_ERR(ts->avdd)) 1091 + return dev_err_probe(&client->dev, PTR_ERR(ts->avdd), 1092 + "Failed to get 'avdd' regulator\n"); 1097 1093 1098 1094 ts->vccio = devm_regulator_get(&client->dev, "vccio"); 1099 - if (IS_ERR(ts->vccio)) { 1100 - error = PTR_ERR(ts->vccio); 1101 - if (error != -EPROBE_DEFER) 1102 - dev_err(&client->dev, 1103 - "Failed to get 'vccio' regulator: %d\n", error); 1104 - return error; 1105 - } 1095 + if (IS_ERR(ts->vccio)) 1096 + return dev_err_probe(&client->dev, PTR_ERR(ts->vccio), 1097 + "Failed to get 'vccio' regulator\n"); 1106 1098 1107 1099 ts->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", 1108 1100 GPIOD_OUT_LOW); 1109 - if (IS_ERR(ts->reset_gpio)) { 1110 - error = PTR_ERR(ts->reset_gpio); 1111 - if (error != -EPROBE_DEFER) 1112 - dev_err(&client->dev, 1113 - "failed to get reset gpio: %d\n", error); 1114 - return error; 1115 - } 1101 + if (IS_ERR(ts->reset_gpio)) 1102 + return dev_err_probe(&client->dev, PTR_ERR(ts->reset_gpio), 1103 + "Failed to get reset gpio\n"); 1116 1104 1117 1105 error = raydium_i2c_power_on(ts); 1118 1106 if (error)
+2 -6
drivers/input/touchscreen/resistive-adc-touch.c
··· 210 210 211 211 /* get the channels from IIO device */ 212 212 st->iio_chans = devm_iio_channel_get_all(dev); 213 - if (IS_ERR(st->iio_chans)) { 214 - error = PTR_ERR(st->iio_chans); 215 - if (error != -EPROBE_DEFER) 216 - dev_err(dev, "can't get iio channels.\n"); 217 - return error; 218 - } 213 + if (IS_ERR(st->iio_chans)) 214 + return dev_err_probe(dev, PTR_ERR(st->iio_chans), "can't get iio channels\n"); 219 215 220 216 if (!device_property_present(dev, "io-channel-names")) 221 217 return -ENODEV;
+3 -5
drivers/input/touchscreen/silead.c
··· 706 706 707 707 /* Power GPIO pin */ 708 708 data->gpio_power = devm_gpiod_get_optional(dev, "power", GPIOD_OUT_LOW); 709 - if (IS_ERR(data->gpio_power)) { 710 - if (PTR_ERR(data->gpio_power) != -EPROBE_DEFER) 711 - dev_err(dev, "Shutdown GPIO request failed\n"); 712 - return PTR_ERR(data->gpio_power); 713 - } 709 + if (IS_ERR(data->gpio_power)) 710 + return dev_err_probe(dev, PTR_ERR(data->gpio_power), 711 + "Shutdown GPIO request failed\n"); 714 712 715 713 error = silead_ts_setup(client); 716 714 if (error)
+6 -14
drivers/input/touchscreen/sis_i2c.c
··· 310 310 311 311 ts->attn_gpio = devm_gpiod_get_optional(&client->dev, 312 312 "attn", GPIOD_IN); 313 - if (IS_ERR(ts->attn_gpio)) { 314 - error = PTR_ERR(ts->attn_gpio); 315 - if (error != -EPROBE_DEFER) 316 - dev_err(&client->dev, 317 - "Failed to get attention GPIO: %d\n", error); 318 - return error; 319 - } 313 + if (IS_ERR(ts->attn_gpio)) 314 + return dev_err_probe(&client->dev, PTR_ERR(ts->attn_gpio), 315 + "Failed to get attention GPIO\n"); 320 316 321 317 ts->reset_gpio = devm_gpiod_get_optional(&client->dev, 322 318 "reset", GPIOD_OUT_LOW); 323 - if (IS_ERR(ts->reset_gpio)) { 324 - error = PTR_ERR(ts->reset_gpio); 325 - if (error != -EPROBE_DEFER) 326 - dev_err(&client->dev, 327 - "Failed to get reset GPIO: %d\n", error); 328 - return error; 329 - } 319 + if (IS_ERR(ts->reset_gpio)) 320 + return dev_err_probe(&client->dev, PTR_ERR(ts->reset_gpio), 321 + "Failed to get reset GPIO\n"); 330 322 331 323 sis_ts_reset(ts); 332 324
+3 -10
drivers/input/touchscreen/surface3_spi.c
··· 221 221 */ 222 222 static int surface3_spi_get_gpio_config(struct surface3_ts_data *data) 223 223 { 224 - int error; 225 224 struct device *dev; 226 225 struct gpio_desc *gpiod; 227 226 int i; ··· 230 231 /* Get the reset lines GPIO pin number */ 231 232 for (i = 0; i < 2; i++) { 232 233 gpiod = devm_gpiod_get_index(dev, NULL, i, GPIOD_OUT_LOW); 233 - if (IS_ERR(gpiod)) { 234 - error = PTR_ERR(gpiod); 235 - if (error != -EPROBE_DEFER) 236 - dev_err(dev, 237 - "Failed to get power GPIO %d: %d\n", 238 - i, 239 - error); 240 - return error; 241 - } 234 + if (IS_ERR(gpiod)) 235 + return dev_err_probe(dev, PTR_ERR(gpiod), 236 + "Failed to get power GPIO %d\n", i); 242 237 243 238 data->gpiod_rst[i] = gpiod; 244 239 }
+3 -7
drivers/input/touchscreen/sx8654.c
··· 323 323 324 324 sx8654->gpio_reset = devm_gpiod_get_optional(&client->dev, "reset", 325 325 GPIOD_OUT_HIGH); 326 - if (IS_ERR(sx8654->gpio_reset)) { 327 - error = PTR_ERR(sx8654->gpio_reset); 328 - if (error != -EPROBE_DEFER) 329 - dev_err(&client->dev, "unable to get reset-gpio: %d\n", 330 - error); 331 - return error; 332 - } 326 + if (IS_ERR(sx8654->gpio_reset)) 327 + return dev_err_probe(&client->dev, PTR_ERR(sx8654->gpio_reset), 328 + "unable to get reset-gpio\n"); 333 329 dev_dbg(&client->dev, "got GPIO reset pin\n"); 334 330 335 331 sx8654->data = device_get_match_data(&client->dev);
-1
drivers/input/touchscreen/ti_am335x_tsc.c
··· 25 25 #include <linux/io.h> 26 26 #include <linux/delay.h> 27 27 #include <linux/of.h> 28 - #include <linux/of_device.h> 29 28 #include <linux/sort.h> 30 29 #include <linux/pm_wakeirq.h> 31 30
+1 -1
include/linux/gameport.h
··· 63 63 int gameport_open(struct gameport *gameport, struct gameport_driver *drv, int mode); 64 64 void gameport_close(struct gameport *gameport); 65 65 66 - #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) 66 + #if IS_REACHABLE(CONFIG_GAMEPORT) 67 67 68 68 void __gameport_register_port(struct gameport *gameport, struct module *owner); 69 69 /* use a define to avoid include chaining to get THIS_MODULE */
-1
include/linux/tca6416_keypad.h
··· 25 25 unsigned int rep:1; /* enable input subsystem auto repeat */ 26 26 uint16_t pinmask; 27 27 uint16_t invert; 28 - int irq_is_gpio; 29 28 int use_polling; /* use polling if Interrupt is not connected*/ 30 29 }; 31 30 #endif