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

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull input updates from Dmitry Torokhov:

- support for inhibiting input devices at request from userspace. If a
device implements open/close methods, it can also put device into low
power state. This is needed, for example, to disable keyboard and
touchpad on convertibles when they are transitioned into tablet mode

- now that ordinary input devices can be configured for polling mode,
dedicated input polling device implementation has been removed

- GTCO tablet driver has been removed, as it used problematic custom
HID parser, devices are EOL, and there is no interest from the
manufacturer

- a new driver for Dialog DA7280 haptic chips has been introduced

- a new driver for power button on Dell Wyse 3020

- support for eKTF2132 in ektf2127 driver

- support for SC2721 and SC2730 in sc27xx-vibra driver

- enhancements for Atmel touchscreens, AD7846 touchscreens, Elan
touchpads, ADP5589, ST1232 touchscreen, TM2 touchkey drivers

- fixes and cleanups to allow clean builds with W=1

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (86 commits)
Input: da7280 - fix spelling mistake "sequemce" -> "sequence"
Input: cyapa_gen6 - fix out-of-bounds stack access
Input: sc27xx - add support for sc2730 and sc2721
dt-bindings: input: Add compatible string for SC2721 and SC2730
dt-bindings: input: Convert sc27xx-vibra.txt to json-schema
Input: stmpe - add axis inversion and swapping capability
Input: adp5589-keys - do not explicitly control IRQ for wakeup
Input: adp5589-keys - do not unconditionally configure as wakeup source
Input: ipx4xx-beeper - convert comma to semicolon
Input: parkbd - convert comma to semicolon
Input: new da7280 haptic driver
dt-bindings: input: Add document bindings for DA7280
MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
Input: elantech - fix protocol errors for some trackpoints in SMBus mode
Input: elan_i2c - add new trackpoint report type 0x5F
Input: elants - document some registers and values
Input: atmel_mxt_ts - simplify the return expression of mxt_send_bootloader_cmd()
Input: imx_keypad - add COMPILE_TEST support
Input: applespi - use new structure for SPI transfer delays
Input: synaptics-rmi4 - use new structure for SPI transfer delays
...

+2991 -2383
+57
Documentation/devicetree/bindings/input/ariel-pwrbutton.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/input/ariel-pwrbutton.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Dell Wyse 3020 a.k.a. "Ariel" Power Button 8 + 9 + maintainers: 10 + - Lubomir Rintel <lkundrak@v3.sk> 11 + 12 + description: | 13 + The ENE Embedded Controller on the Ariel board has an interface to the 14 + SPI bus that is capable of sending keyboard and mouse data. A single 15 + power button is attached to it. This binding describes this 16 + configuration. 17 + 18 + allOf: 19 + - $ref: input.yaml# 20 + 21 + properties: 22 + compatible: 23 + items: 24 + - const: dell,wyse-ariel-ec-input 25 + - const: ene,kb3930-input 26 + 27 + reg: 28 + maxItems: 1 29 + 30 + interrupts: 31 + maxItems: 1 32 + 33 + spi-max-frequency: true 34 + 35 + required: 36 + - compatible 37 + - reg 38 + - interrupts 39 + 40 + additionalProperties: false 41 + 42 + examples: 43 + - | 44 + #include <dt-bindings/interrupt-controller/irq.h> 45 + 46 + spi { 47 + #address-cells = <1>; 48 + #size-cells = <0>; 49 + 50 + power-button@0 { 51 + compatible = "dell,wyse-ariel-ec-input", "ene,kb3930-input"; 52 + reg = <0>; 53 + interrupt-parent = <&gpio>; 54 + interrupts = <60 IRQ_TYPE_EDGE_RISING>; 55 + spi-max-frequency = <33000000>; 56 + }; 57 + };
-41
Documentation/devicetree/bindings/input/atmel,maxtouch.txt
··· 1 - Atmel maXTouch touchscreen/touchpad 2 - 3 - Required properties: 4 - - compatible: 5 - atmel,maxtouch 6 - 7 - The following compatibles have been used in various products but are 8 - deprecated: 9 - atmel,qt602240_ts 10 - atmel,atmel_mxt_ts 11 - atmel,atmel_mxt_tp 12 - atmel,mXT224 13 - 14 - - reg: The I2C address of the device 15 - 16 - - interrupts: The sink for the touchpad's IRQ output 17 - See ../interrupt-controller/interrupts.txt 18 - 19 - Optional properties for main touchpad device: 20 - 21 - - linux,gpio-keymap: When enabled, the SPT_GPIOPWN_T19 object sends messages 22 - on GPIO bit changes. An array of up to 8 entries can be provided 23 - indicating the Linux keycode mapped to each bit of the status byte, 24 - starting at the LSB. Linux keycodes are defined in 25 - <dt-bindings/input/input.h>. 26 - 27 - Note: the numbering of the GPIOs and the bit they start at varies between 28 - maXTouch devices. You must either refer to the documentation, or 29 - experiment to determine which bit corresponds to which input. Use 30 - KEY_RESERVED for unused padding values. 31 - 32 - - reset-gpios: GPIO specifier for the touchscreen's reset pin (active low) 33 - 34 - Example: 35 - 36 - touch@4b { 37 - compatible = "atmel,maxtouch"; 38 - reg = <0x4b>; 39 - interrupt-parent = <&gpio>; 40 - interrupts = <TEGRA_GPIO(W, 3) IRQ_TYPE_LEVEL_LOW>; 41 - };
+81
Documentation/devicetree/bindings/input/atmel,maxtouch.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/atmel,maxtouch.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Atmel maXTouch touchscreen/touchpad 8 + 9 + maintainers: 10 + - Nick Dyer <nick@shmanahar.org> 11 + - Linus Walleij <linus.walleij@linaro.org> 12 + 13 + description: | 14 + Atmel maXTouch touchscreen or touchpads such as the mXT244 15 + and similar devices. 16 + 17 + properties: 18 + compatible: 19 + const: atmel,maxtouch 20 + 21 + reg: 22 + maxItems: 1 23 + 24 + interrupts: 25 + maxItems: 1 26 + 27 + vdda-supply: 28 + description: 29 + Optional regulator for the AVDD analog voltage. 30 + 31 + vdd-supply: 32 + description: 33 + Optional regulator for the VDD digital voltage. 34 + 35 + reset-gpios: 36 + maxItems: 1 37 + description: 38 + Optional GPIO specifier for the touchscreen's reset pin 39 + (active low). The line must be flagged with 40 + GPIO_ACTIVE_LOW. 41 + 42 + linux,gpio-keymap: 43 + $ref: /schemas/types.yaml#/definitions/uint32-array 44 + description: | 45 + When enabled, the SPT_GPIOPWN_T19 object sends messages 46 + on GPIO bit changes. An array of up to 8 entries can be provided 47 + indicating the Linux keycode mapped to each bit of the status byte, 48 + starting at the LSB. Linux keycodes are defined in 49 + <dt-bindings/input/input.h>. 50 + 51 + Note: the numbering of the GPIOs and the bit they start at varies 52 + between maXTouch devices. You must either refer to the documentation, 53 + or experiment to determine which bit corresponds to which input. Use 54 + KEY_RESERVED for unused padding values. 55 + 56 + required: 57 + - compatible 58 + - reg 59 + - interrupts 60 + 61 + additionalProperties: false 62 + 63 + examples: 64 + - | 65 + #include <dt-bindings/interrupt-controller/irq.h> 66 + #include <dt-bindings/gpio/gpio.h> 67 + i2c { 68 + #address-cells = <1>; 69 + #size-cells = <0>; 70 + touchscreen@4a { 71 + compatible = "atmel,maxtouch"; 72 + reg = <0x4a>; 73 + interrupt-parent = <&gpio>; 74 + interrupts = <26 IRQ_TYPE_EDGE_FALLING>; 75 + reset-gpios = <&gpio 27 GPIO_ACTIVE_LOW>; 76 + vdda-supply = <&ab8500_ldo_aux2_reg>; 77 + vdd-supply = <&ab8500_ldo_aux5_reg>; 78 + }; 79 + }; 80 + 81 + ...
-33
Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
··· 1 - Samsung tm2-touchkey 2 - 3 - Required properties: 4 - - compatible: 5 - * "cypress,tm2-touchkey" - for the touchkey found on the tm2 board 6 - * "cypress,midas-touchkey" - for the touchkey found on midas boards 7 - * "cypress,aries-touchkey" - for the touchkey found on aries boards 8 - * "coreriver,tc360-touchkey" - for the Coreriver TouchCore 360 touchkey 9 - - reg: I2C address of the chip. 10 - - interrupts: interrupt to which the chip is connected (see interrupt 11 - binding[0]). 12 - - vcc-supply : internal regulator output. 1.8V 13 - - vdd-supply : power supply for IC 3.3V 14 - 15 - Optional properties: 16 - - linux,keycodes: array of keycodes (max 4), default KEY_PHONE and KEY_BACK 17 - 18 - [0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt 19 - 20 - Example: 21 - &i2c0 { 22 - /* ... */ 23 - 24 - touchkey@20 { 25 - compatible = "cypress,tm2-touchkey"; 26 - reg = <0x20>; 27 - interrupt-parent = <&gpa3>; 28 - interrupts = <2 IRQ_TYPE_EDGE_FALLING>; 29 - vcc-supply=<&ldo32_reg>; 30 - vdd-supply=<&ldo33_reg>; 31 - linux,keycodes = <KEY_PHONE KEY_BACK>; 32 - }; 33 - };
+73
Documentation/devicetree/bindings/input/cypress,tm2-touchkey.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/input/cypress,tm2-touchkey.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Samsung TM2 touch key controller 8 + 9 + maintainers: 10 + - Stephan Gerhold <stephan@gerhold.net> 11 + 12 + description: | 13 + Touch key controllers similar to the TM2 can be found in a wide range of 14 + Samsung devices. They are implemented using many different MCUs, but use 15 + a similar I2C protocol. 16 + 17 + allOf: 18 + - $ref: input.yaml# 19 + 20 + properties: 21 + compatible: 22 + enum: 23 + - cypress,tm2-touchkey 24 + - cypress,midas-touchkey 25 + - cypress,aries-touchkey 26 + - coreriver,tc360-touchkey 27 + 28 + reg: 29 + maxItems: 1 30 + 31 + interrupts: 32 + maxItems: 1 33 + 34 + vdd-supply: 35 + description: Optional regulator for LED voltage, 3.3V. 36 + 37 + vcc-supply: 38 + description: Optional regulator for MCU, 1.8V-3.3V (depending on MCU). 39 + 40 + vddio-supply: 41 + description: | 42 + Optional regulator that provides digital I/O voltage, 43 + e.g. for pulling up the interrupt line or the I2C pins. 44 + 45 + linux,keycodes: 46 + minItems: 1 47 + maxItems: 4 48 + 49 + required: 50 + - compatible 51 + - reg 52 + - interrupts 53 + 54 + additionalProperties: false 55 + 56 + examples: 57 + - | 58 + #include <dt-bindings/input/input.h> 59 + #include <dt-bindings/interrupt-controller/irq.h> 60 + i2c { 61 + #address-cells = <1>; 62 + #size-cells = <0>; 63 + 64 + touchkey@20 { 65 + compatible = "cypress,tm2-touchkey"; 66 + reg = <0x20>; 67 + interrupt-parent = <&gpa3>; 68 + interrupts = <2 IRQ_TYPE_EDGE_FALLING>; 69 + vcc-supply = <&ldo32_reg>; 70 + vdd-supply = <&ldo33_reg>; 71 + linux,keycodes = <KEY_MENU KEY_BACK>; 72 + }; 73 + };
+108
Documentation/devicetree/bindings/input/dlg,da7280.txt
··· 1 + Dialog Semiconductor DA7280 Haptics bindings 2 + 3 + Required properties: 4 + - compatible: Should be "dlg,da7280". 5 + - reg: Specifies the I2C slave address. 6 + 7 + - interrupt-parent : Specifies the phandle of the interrupt controller to 8 + which the IRQs from DA7280 are delivered to. 9 + 10 + - dlg,actuator-type: Set Actuator type. it should be one of: 11 + "LRA" - Linear Resonance Actuator type. 12 + "ERM-bar" - Bar type Eccentric Rotating Mass. 13 + "ERM-coin" - Coin type Eccentric Rotating Mass. 14 + 15 + - dlg,const-op-mode: Haptic operation mode for FF_CONSTANT. 16 + Possible values: 17 + 1 - Direct register override(DRO) mode triggered by i2c(default), 18 + 2 - PWM data source mode controlled by PWM duty, 19 + - dlg,periodic-op-mode: Haptic operation mode for FF_PERIODIC. 20 + Possible values: 21 + 1 - Register triggered waveform memory(RTWM) mode, the pattern 22 + assigned to the PS_SEQ_ID played as much times as PS_SEQ_LOOP, 23 + 2 - Edge triggered waveform memory(ETWM) mode, external GPI(N) 24 + control are required to enable/disable and it needs to keep 25 + device enabled by sending magnitude (X > 0), 26 + the pattern is assigned to the GPI(N)_SEQUENCE_ID below. 27 + The default value is 1 for both of the operation modes. 28 + For more details, please see the datasheet. 29 + 30 + - dlg,nom-microvolt: Nominal actuator voltage rating. 31 + Valid values: 0 - 6000000. 32 + - dlg,abs-max-microvolt: Absolute actuator maximum voltage rating. 33 + Valid values: 0 - 6000000. 34 + - dlg,imax-microamp: Actuator max current rating. 35 + Valid values: 0 - 252000. 36 + Default: 130000. 37 + - dlg,impd-micro-ohms: the impedance of the actuator in micro ohms. 38 + Valid values: 0 - 1500000000. 39 + 40 + Optional properties: 41 + - pwms : phandle to the physical PWM(Pulse Width Modulation) device. 42 + PWM properties should be named "pwms". And number of cell is different 43 + for each pwm device. 44 + (See Documentation/devicetree/bindings/pwm/pwm.txt 45 + for further information relating to pwm properties) 46 + 47 + - dlg,ps-seq-id: the PS_SEQ_ID(pattern ID in waveform memory inside chip) 48 + to play back when RTWM-MODE is enabled. 49 + Valid range: 0 - 15. 50 + - dlg,ps-seq-loop: the PS_SEQ_LOOP, Number of times the pre-stored sequence 51 + pointed to by PS_SEQ_ID or GPI(N)_SEQUENCE_ID is repeated. 52 + Valid range: 0 - 15. 53 + - dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play 54 + when gpi0 is triggered, 'N' must be 0 - 2. 55 + Valid range: 0 - 15. 56 + - dlg,gpiN-mode: the pattern mode which can select either 57 + "Single-pattern" or "Multi-pattern", 'N' must be 0 - 2. 58 + - dlg,gpiN-polarity: gpiN polarity which can be chosen among 59 + "Rising-edge", "Falling-edge" and "Both-edge", 60 + 'N' must be 0 - 2 61 + Haptic will work by this edge option in case of ETWM mode. 62 + 63 + - dlg,resonant-freq-hz: use in case of LRA. 64 + the frequency range: 50 - 300. 65 + Default: 205. 66 + 67 + - dlg,bemf-sens-enable: Enable for internal loop computations. 68 + - dlg,freq-track-enable: Enable for resonant frequency tracking. 69 + - dlg,acc-enable: Enable for active acceleration. 70 + - dlg,rapid-stop-enable: Enable for rapid stop. 71 + - dlg,amp-pid-enable: Enable for the amplitude PID. 72 + - dlg,mem-array: Customized waveform memory(patterns) data downloaded to 73 + the device during initialization. This is an array of 100 values(u8). 74 + 75 + For further information, see device datasheet. 76 + 77 + ====== 78 + 79 + Example: 80 + 81 + haptics: da7280-haptics@4a { 82 + compatible = "dlg,da7280"; 83 + reg = <0x4a>; 84 + interrupt-parent = <&gpio6>; 85 + interrupts = <11 IRQ_TYPE_LEVEL_LOW>; 86 + dlg,actuator-type = "LRA"; 87 + dlg,dlg,const-op-mode = <1>; 88 + dlg,dlg,periodic-op-mode = <1>; 89 + dlg,nom-microvolt = <2000000>; 90 + dlg,abs-max-microvolt = <2000000>; 91 + dlg,imax-microamp = <170000>; 92 + dlg,resonant-freq-hz = <180>; 93 + dlg,impd-micro-ohms = <10500000>; 94 + dlg,freq-track-enable; 95 + dlg,rapid-stop-enable; 96 + dlg,mem-array = < 97 + 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 98 + 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 99 + 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 100 + 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 101 + 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 102 + 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 103 + 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 104 + 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 105 + 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 106 + 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 107 + >; 108 + };
-23
Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt
··· 1 - Spreadtrum SC27xx PMIC Vibrator 2 - 3 - Required properties: 4 - - compatible: should be "sprd,sc2731-vibrator". 5 - - reg: address of vibrator control register. 6 - 7 - Example : 8 - 9 - sc2731_pmic: pmic@0 { 10 - compatible = "sprd,sc2731"; 11 - reg = <0>; 12 - spi-max-frequency = <26000000>; 13 - interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>; 14 - interrupt-controller; 15 - #interrupt-cells = <2>; 16 - #address-cells = <1>; 17 - #size-cells = <0>; 18 - 19 - vibrator@eb4 { 20 - compatible = "sprd,sc2731-vibrator"; 21 - reg = <0xeb4>; 22 - }; 23 - };
+48
Documentation/devicetree/bindings/input/sprd,sc27xx-vibrator.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + # Copyright 2020 Unisoc Inc. 3 + %YAML 1.2 4 + --- 5 + $id: http://devicetree.org/schemas/input/sprd,sc27xx-vibrator.yaml# 6 + $schema: http://devicetree.org/meta-schemas/core.yaml# 7 + 8 + title: Spreadtrum SC27xx PMIC Vibrator Device Tree Bindings 9 + 10 + maintainers: 11 + - Orson Zhai <orsonzhai@gmail.com> 12 + - Baolin Wang <baolin.wang7@gmail.com> 13 + - Chunyan Zhang <zhang.lyra@gmail.com> 14 + 15 + properties: 16 + compatible: 17 + enum: 18 + - sprd,sc2721-vibrator 19 + - sprd,sc2730-vibrator 20 + - sprd,sc2731-vibrator 21 + 22 + reg: 23 + maxItems: 1 24 + 25 + required: 26 + - compatible 27 + - reg 28 + 29 + additionalProperties: false 30 + 31 + examples: 32 + - | 33 + #include <dt-bindings/interrupt-controller/arm-gic.h> 34 + sc2731_pmic: pmic@0 { 35 + compatible = "sprd,sc2731"; 36 + reg = <0 0>; 37 + spi-max-frequency = <26000000>; 38 + interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>; 39 + interrupt-controller; 40 + #interrupt-cells = <2>; 41 + #address-cells = <1>; 42 + #size-cells = <0>; 43 + 44 + vibrator@eb4 { 45 + compatible = "sprd,sc2731-vibrator"; 46 + reg = <0xeb4>; 47 + }; 48 + };
+1 -1
Documentation/devicetree/bindings/input/touchscreen/ektf2127.txt
··· 1 1 * Elan eKTF2127 I2C touchscreen controller 2 2 3 3 Required properties: 4 - - compatible : "elan,ektf2127" 4 + - compatible : "elan,ektf2127" or "elan,ektf2132" 5 5 - reg : I2C slave address of the chip (0x40) 6 6 - interrupts : interrupt specification for the ektf2127 interrupt 7 7 - power-gpios : GPIO specification for the pin connected to the
-9
Documentation/driver-api/input.rst
··· 25 25 .. kernel-doc:: drivers/input/input-mt.c 26 26 :export: 27 27 28 - Polled input devices 29 - -------------------- 30 - 31 - .. kernel-doc:: include/linux/input-polldev.h 32 - :internal: 33 - 34 - .. kernel-doc:: drivers/input/input-polldev.c 35 - :export: 36 - 37 28 Matrix keyboards/keypads 38 29 ------------------------ 39 30
+46
Documentation/input/input-programming.rst
··· 164 164 The open() callback should return a 0 in case of success or any nonzero value 165 165 in case of failure. The close() callback (which is void) must always succeed. 166 166 167 + Inhibiting input devices 168 + ~~~~~~~~~~~~~~~~~~~~~~~~ 169 + 170 + Inhibiting a device means ignoring input events from it. As such it is about 171 + maintaining relationships with input handlers - either already existing 172 + relationships, or relationships to be established while the device is in 173 + inhibited state. 174 + 175 + If a device is inhibited, no input handler will receive events from it. 176 + 177 + The fact that nobody wants events from the device is exploited further, by 178 + calling device's close() (if there are users) and open() (if there are users) on 179 + inhibit and uninhibit operations, respectively. Indeed, the meaning of close() 180 + is to stop providing events to the input core and that of open() is to start 181 + providing events to the input core. 182 + 183 + Calling the device's close() method on inhibit (if there are users) allows the 184 + driver to save power. Either by directly powering down the device or by 185 + releasing the runtime-pm reference it got in open() when the driver is using 186 + runtime-pm. 187 + 188 + Inhibiting and uninhibiting are orthogonal to opening and closing the device by 189 + input handlers. Userspace might want to inhibit a device in anticipation before 190 + any handler is positively matched against it. 191 + 192 + Inhibiting and uninhibiting are orthogonal to device's being a wakeup source, 193 + too. Being a wakeup source plays a role when the system is sleeping, not when 194 + the system is operating. How drivers should program their interaction between 195 + inhibiting, sleeping and being a wakeup source is driver-specific. 196 + 197 + Taking the analogy with the network devices - bringing a network interface down 198 + doesn't mean that it should be impossible be wake the system up on LAN through 199 + this interface. So, there may be input drivers which should be considered wakeup 200 + sources even when inhibited. Actually, in many I2C input devices their interrupt 201 + is declared a wakeup interrupt and its handling happens in driver's core, which 202 + is not aware of input-specific inhibit (nor should it be). Composite devices 203 + containing several interfaces can be inhibited on a per-interface basis and e.g. 204 + inhibiting one interface shouldn't affect the device's capability of being a 205 + wakeup source. 206 + 207 + If a device is to be considered a wakeup source while inhibited, special care 208 + must be taken when programming its suspend(), as it might need to call device's 209 + open(). Depending on what close() means for the device in question, not 210 + opening() it before going to sleep might make it impossible to provide any 211 + wakeup events. The device is going to sleep anyway. 212 + 167 213 Basic event types 168 214 ~~~~~~~~~~~~~~~~~ 169 215
+3 -1
MAINTAINERS
··· 2966 2966 M: Nick Dyer <nick@shmanahar.org> 2967 2967 S: Maintained 2968 2968 T: git git://github.com/ndyer/linux.git 2969 - F: Documentation/devicetree/bindings/input/atmel,maxtouch.txt 2969 + F: Documentation/devicetree/bindings/input/atmel,maxtouch.yaml 2970 2970 F: drivers/input/touchscreen/atmel_mxt_ts.c 2971 2971 2972 2972 ATMEL WIRELESS DRIVER ··· 5159 5159 S: Supported 5160 5160 W: http://www.dialog-semiconductor.com/products 5161 5161 F: Documentation/devicetree/bindings/input/da90??-onkey.txt 5162 + F: Documentation/devicetree/bindings/input/dlg,da72??.txt 5162 5163 F: Documentation/devicetree/bindings/mfd/da90*.txt 5163 5164 F: Documentation/devicetree/bindings/regulator/dlg,da9*.yaml 5164 5165 F: Documentation/devicetree/bindings/regulator/da92*.txt ··· 5171 5170 F: drivers/gpio/gpio-da90??.c 5172 5171 F: drivers/hwmon/da90??-hwmon.c 5173 5172 F: drivers/iio/adc/da91??-*.c 5173 + F: drivers/input/misc/da72??.[ch] 5174 5174 F: drivers/input/misc/da90??_onkey.c 5175 5175 F: drivers/input/touchscreen/da9052_tsi.c 5176 5176 F: drivers/leds/leds-da90??.c
+1 -1
arch/arm/boot/dts/imx53-ppd.dts
··· 589 589 590 590 touchscreen@4b { 591 591 compatible = "atmel,maxtouch"; 592 - reset-gpio = <&gpio5 19 GPIO_ACTIVE_HIGH>; 592 + reset-gpio = <&gpio5 19 GPIO_ACTIVE_LOW>; 593 593 reg = <0x4b>; 594 594 interrupt-parent = <&gpio5>; 595 595 interrupts = <4 IRQ_TYPE_LEVEL_LOW>;
+1 -1
arch/arm/boot/dts/imx6dl-colibri-eval-v3.dts
··· 143 143 reg = <0x4a>; 144 144 interrupt-parent = <&gpio1>; 145 145 interrupts = <9 IRQ_TYPE_EDGE_FALLING>; /* SODIMM 28 */ 146 - reset-gpios = <&gpio2 10 GPIO_ACTIVE_HIGH>; /* SODIMM 30 */ 146 + reset-gpios = <&gpio2 10 GPIO_ACTIVE_LOW>; /* SODIMM 30 */ 147 147 status = "disabled"; 148 148 }; 149 149
+1 -1
arch/arm/boot/dts/imx6q-apalis-eval.dts
··· 140 140 reg = <0x4a>; 141 141 interrupt-parent = <&gpio6>; 142 142 interrupts = <10 IRQ_TYPE_EDGE_FALLING>; 143 - reset-gpios = <&gpio6 9 GPIO_ACTIVE_HIGH>; /* SODIMM 13 */ 143 + reset-gpios = <&gpio6 9 GPIO_ACTIVE_LOW>; /* SODIMM 13 */ 144 144 status = "disabled"; 145 145 }; 146 146
+1 -1
arch/arm/boot/dts/imx6q-apalis-ixora-v1.1.dts
··· 145 145 reg = <0x4a>; 146 146 interrupt-parent = <&gpio6>; 147 147 interrupts = <10 IRQ_TYPE_EDGE_FALLING>; 148 - reset-gpios = <&gpio6 9 GPIO_ACTIVE_HIGH>; /* SODIMM 13 */ 148 + reset-gpios = <&gpio6 9 GPIO_ACTIVE_LOW>; /* SODIMM 13 */ 149 149 status = "disabled"; 150 150 }; 151 151
+1 -1
arch/arm/boot/dts/imx6q-apalis-ixora.dts
··· 144 144 reg = <0x4a>; 145 145 interrupt-parent = <&gpio6>; 146 146 interrupts = <10 IRQ_TYPE_EDGE_FALLING>; 147 - reset-gpios = <&gpio6 9 GPIO_ACTIVE_HIGH>; /* SODIMM 13 */ 147 + reset-gpios = <&gpio6 9 GPIO_ACTIVE_LOW>; /* SODIMM 13 */ 148 148 status = "disabled"; 149 149 }; 150 150
+1 -1
arch/arm/boot/dts/imx7-colibri-aster.dtsi
··· 99 99 reg = <0x4a>; 100 100 interrupt-parent = <&gpio2>; 101 101 interrupts = <15 IRQ_TYPE_EDGE_FALLING>; /* SODIMM 107 */ 102 - reset-gpios = <&gpio2 28 GPIO_ACTIVE_HIGH>; /* SODIMM 106 */ 102 + reset-gpios = <&gpio2 28 GPIO_ACTIVE_LOW>; /* SODIMM 106 */ 103 103 }; 104 104 105 105 /* M41T0M6 real time clock on carrier board */
+1 -1
arch/arm/boot/dts/imx7-colibri-eval-v3.dtsi
··· 124 124 reg = <0x4a>; 125 125 interrupt-parent = <&gpio1>; 126 126 interrupts = <9 IRQ_TYPE_EDGE_FALLING>; /* SODIMM 28 */ 127 - reset-gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>; /* SODIMM 30 */ 127 + reset-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>; /* SODIMM 30 */ 128 128 status = "disabled"; 129 129 }; 130 130
+1 -1
arch/arm/boot/dts/motorola-mapphone-common.dtsi
··· 430 430 pinctrl-names = "default"; 431 431 pinctrl-0 = <&touchscreen_pins>; 432 432 433 - reset-gpios = <&gpio6 13 GPIO_ACTIVE_HIGH>; /* gpio173 */ 433 + reset-gpios = <&gpio6 13 GPIO_ACTIVE_LOW>; /* gpio173 */ 434 434 435 435 /* gpio_183 with sys_nirq2 pad as wakeup */ 436 436 interrupts-extended = <&gpio6 23 IRQ_TYPE_LEVEL_LOW>,
+1 -1
arch/arm/boot/dts/s5pv210-aries.dtsi
··· 632 632 interrupts = <5 IRQ_TYPE_EDGE_FALLING>; 633 633 pinctrl-names = "default"; 634 634 pinctrl-0 = <&ts_irq>; 635 - reset-gpios = <&gpj1 3 GPIO_ACTIVE_HIGH>; 635 + reset-gpios = <&gpj1 3 GPIO_ACTIVE_LOW>; 636 636 }; 637 637 }; 638 638
+1 -1
arch/arm/boot/dts/tegra20-acer-a500-picasso.dts
··· 446 446 interrupt-parent = <&gpio>; 447 447 interrupts = <TEGRA_GPIO(V, 6) IRQ_TYPE_LEVEL_LOW>; 448 448 449 - reset-gpios = <&gpio TEGRA_GPIO(Q, 7) GPIO_ACTIVE_HIGH>; 449 + reset-gpios = <&gpio TEGRA_GPIO(Q, 7) GPIO_ACTIVE_LOW>; 450 450 451 451 avdd-supply = <&vdd_3v3_sys>; 452 452 vdd-supply = <&vdd_3v3_sys>;
-1
arch/powerpc/configs/ppc6xx_defconfig
··· 579 579 CONFIG_INPUT_TABLET=y 580 580 CONFIG_TABLET_USB_ACECAD=m 581 581 CONFIG_TABLET_USB_AIPTEK=m 582 - CONFIG_TABLET_USB_GTCO=m 583 582 CONFIG_TABLET_USB_KBTAB=m 584 583 CONFIG_INPUT_MISC=y 585 584 CONFIG_INPUT_PCSPKR=m
-13
drivers/input/Kconfig
··· 52 52 To compile this driver as a module, choose M here: the 53 53 module will be called ff-memless. 54 54 55 - config INPUT_POLLDEV 56 - tristate "Polled input device skeleton" 57 - help 58 - Say Y here if you are using a driver for an input 59 - device that periodically polls hardware state. This 60 - option is only useful for out-of-tree drivers since 61 - in-tree drivers select it automatically. 62 - 63 - If unsure, say N. 64 - 65 - To compile this driver as a module, choose M here: the 66 - module will be called input-polldev. 67 - 68 55 config INPUT_SPARSEKMAP 69 56 tristate "Sparse keymap support library" 70 57 help
-1
drivers/input/Makefile
··· 9 9 input-core-y := input.o input-compat.o input-mt.o input-poller.o ff-core.o 10 10 11 11 obj-$(CONFIG_INPUT_FF_MEMLESS) += ff-memless.o 12 - obj-$(CONFIG_INPUT_POLLDEV) += input-polldev.o 13 12 obj-$(CONFIG_INPUT_SPARSEKMAP) += sparse-keymap.o 14 13 obj-$(CONFIG_INPUT_MATRIXKMAP) += matrix-keymap.o 15 14
-362
drivers/input/input-polldev.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-only 2 - /* 3 - * Generic implementation of a polled input device 4 - 5 - * Copyright (c) 2007 Dmitry Torokhov 6 - */ 7 - 8 - #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 9 - 10 - #include <linux/jiffies.h> 11 - #include <linux/slab.h> 12 - #include <linux/mutex.h> 13 - #include <linux/workqueue.h> 14 - #include <linux/module.h> 15 - #include <linux/input-polldev.h> 16 - 17 - MODULE_AUTHOR("Dmitry Torokhov <dtor@mail.ru>"); 18 - MODULE_DESCRIPTION("Generic implementation of a polled input device"); 19 - MODULE_LICENSE("GPL v2"); 20 - 21 - static void input_polldev_queue_work(struct input_polled_dev *dev) 22 - { 23 - unsigned long delay; 24 - 25 - delay = msecs_to_jiffies(dev->poll_interval); 26 - if (delay >= HZ) 27 - delay = round_jiffies_relative(delay); 28 - 29 - queue_delayed_work(system_freezable_wq, &dev->work, delay); 30 - } 31 - 32 - static void input_polled_device_work(struct work_struct *work) 33 - { 34 - struct input_polled_dev *dev = 35 - container_of(work, struct input_polled_dev, work.work); 36 - 37 - dev->poll(dev); 38 - input_polldev_queue_work(dev); 39 - } 40 - 41 - static int input_open_polled_device(struct input_dev *input) 42 - { 43 - struct input_polled_dev *dev = input_get_drvdata(input); 44 - 45 - if (dev->open) 46 - dev->open(dev); 47 - 48 - /* Only start polling if polling is enabled */ 49 - if (dev->poll_interval > 0) { 50 - dev->poll(dev); 51 - input_polldev_queue_work(dev); 52 - } 53 - 54 - return 0; 55 - } 56 - 57 - static void input_close_polled_device(struct input_dev *input) 58 - { 59 - struct input_polled_dev *dev = input_get_drvdata(input); 60 - 61 - cancel_delayed_work_sync(&dev->work); 62 - 63 - if (dev->close) 64 - dev->close(dev); 65 - } 66 - 67 - /* SYSFS interface */ 68 - 69 - static ssize_t input_polldev_get_poll(struct device *dev, 70 - struct device_attribute *attr, char *buf) 71 - { 72 - struct input_polled_dev *polldev = dev_get_drvdata(dev); 73 - 74 - return sprintf(buf, "%d\n", polldev->poll_interval); 75 - } 76 - 77 - static ssize_t input_polldev_set_poll(struct device *dev, 78 - struct device_attribute *attr, const char *buf, 79 - size_t count) 80 - { 81 - struct input_polled_dev *polldev = dev_get_drvdata(dev); 82 - struct input_dev *input = polldev->input; 83 - unsigned int interval; 84 - int err; 85 - 86 - err = kstrtouint(buf, 0, &interval); 87 - if (err) 88 - return err; 89 - 90 - if (interval < polldev->poll_interval_min) 91 - return -EINVAL; 92 - 93 - if (interval > polldev->poll_interval_max) 94 - return -EINVAL; 95 - 96 - mutex_lock(&input->mutex); 97 - 98 - polldev->poll_interval = interval; 99 - 100 - if (input->users) { 101 - cancel_delayed_work_sync(&polldev->work); 102 - if (polldev->poll_interval > 0) 103 - input_polldev_queue_work(polldev); 104 - } 105 - 106 - mutex_unlock(&input->mutex); 107 - 108 - return count; 109 - } 110 - 111 - static DEVICE_ATTR(poll, S_IRUGO | S_IWUSR, input_polldev_get_poll, 112 - input_polldev_set_poll); 113 - 114 - 115 - static ssize_t input_polldev_get_max(struct device *dev, 116 - struct device_attribute *attr, char *buf) 117 - { 118 - struct input_polled_dev *polldev = dev_get_drvdata(dev); 119 - 120 - return sprintf(buf, "%d\n", polldev->poll_interval_max); 121 - } 122 - 123 - static DEVICE_ATTR(max, S_IRUGO, input_polldev_get_max, NULL); 124 - 125 - static ssize_t input_polldev_get_min(struct device *dev, 126 - struct device_attribute *attr, char *buf) 127 - { 128 - struct input_polled_dev *polldev = dev_get_drvdata(dev); 129 - 130 - return sprintf(buf, "%d\n", polldev->poll_interval_min); 131 - } 132 - 133 - static DEVICE_ATTR(min, S_IRUGO, input_polldev_get_min, NULL); 134 - 135 - static struct attribute *sysfs_attrs[] = { 136 - &dev_attr_poll.attr, 137 - &dev_attr_max.attr, 138 - &dev_attr_min.attr, 139 - NULL 140 - }; 141 - 142 - static struct attribute_group input_polldev_attribute_group = { 143 - .attrs = sysfs_attrs 144 - }; 145 - 146 - static const struct attribute_group *input_polldev_attribute_groups[] = { 147 - &input_polldev_attribute_group, 148 - NULL 149 - }; 150 - 151 - /** 152 - * input_allocate_polled_device - allocate memory for polled device 153 - * 154 - * The function allocates memory for a polled device and also 155 - * for an input device associated with this polled device. 156 - */ 157 - struct input_polled_dev *input_allocate_polled_device(void) 158 - { 159 - struct input_polled_dev *dev; 160 - 161 - dev = kzalloc(sizeof(struct input_polled_dev), GFP_KERNEL); 162 - if (!dev) 163 - return NULL; 164 - 165 - dev->input = input_allocate_device(); 166 - if (!dev->input) { 167 - kfree(dev); 168 - return NULL; 169 - } 170 - 171 - return dev; 172 - } 173 - EXPORT_SYMBOL(input_allocate_polled_device); 174 - 175 - struct input_polled_devres { 176 - struct input_polled_dev *polldev; 177 - }; 178 - 179 - static int devm_input_polldev_match(struct device *dev, void *res, void *data) 180 - { 181 - struct input_polled_devres *devres = res; 182 - 183 - return devres->polldev == data; 184 - } 185 - 186 - static void devm_input_polldev_release(struct device *dev, void *res) 187 - { 188 - struct input_polled_devres *devres = res; 189 - struct input_polled_dev *polldev = devres->polldev; 190 - 191 - dev_dbg(dev, "%s: dropping reference/freeing %s\n", 192 - __func__, dev_name(&polldev->input->dev)); 193 - 194 - input_put_device(polldev->input); 195 - kfree(polldev); 196 - } 197 - 198 - static void devm_input_polldev_unregister(struct device *dev, void *res) 199 - { 200 - struct input_polled_devres *devres = res; 201 - struct input_polled_dev *polldev = devres->polldev; 202 - 203 - dev_dbg(dev, "%s: unregistering device %s\n", 204 - __func__, dev_name(&polldev->input->dev)); 205 - input_unregister_device(polldev->input); 206 - 207 - /* 208 - * Note that we are still holding extra reference to the input 209 - * device so it will stick around until devm_input_polldev_release() 210 - * is called. 211 - */ 212 - } 213 - 214 - /** 215 - * devm_input_allocate_polled_device - allocate managed polled device 216 - * @dev: device owning the polled device being created 217 - * 218 - * Returns prepared &struct input_polled_dev or %NULL. 219 - * 220 - * Managed polled input devices do not need to be explicitly unregistered 221 - * or freed as it will be done automatically when owner device unbinds 222 - * from * its driver (or binding fails). Once such managed polled device 223 - * is allocated, it is ready to be set up and registered in the same 224 - * fashion as regular polled input devices (using 225 - * input_register_polled_device() function). 226 - * 227 - * If you want to manually unregister and free such managed polled devices, 228 - * it can be still done by calling input_unregister_polled_device() and 229 - * input_free_polled_device(), although it is rarely needed. 230 - * 231 - * NOTE: the owner device is set up as parent of input device and users 232 - * should not override it. 233 - */ 234 - struct input_polled_dev *devm_input_allocate_polled_device(struct device *dev) 235 - { 236 - struct input_polled_dev *polldev; 237 - struct input_polled_devres *devres; 238 - 239 - devres = devres_alloc(devm_input_polldev_release, sizeof(*devres), 240 - GFP_KERNEL); 241 - if (!devres) 242 - return NULL; 243 - 244 - polldev = input_allocate_polled_device(); 245 - if (!polldev) { 246 - devres_free(devres); 247 - return NULL; 248 - } 249 - 250 - polldev->input->dev.parent = dev; 251 - polldev->devres_managed = true; 252 - 253 - devres->polldev = polldev; 254 - devres_add(dev, devres); 255 - 256 - return polldev; 257 - } 258 - EXPORT_SYMBOL(devm_input_allocate_polled_device); 259 - 260 - /** 261 - * input_free_polled_device - free memory allocated for polled device 262 - * @dev: device to free 263 - * 264 - * The function frees memory allocated for polling device and drops 265 - * reference to the associated input device. 266 - */ 267 - void input_free_polled_device(struct input_polled_dev *dev) 268 - { 269 - if (dev) { 270 - if (dev->devres_managed) 271 - WARN_ON(devres_destroy(dev->input->dev.parent, 272 - devm_input_polldev_release, 273 - devm_input_polldev_match, 274 - dev)); 275 - input_put_device(dev->input); 276 - kfree(dev); 277 - } 278 - } 279 - EXPORT_SYMBOL(input_free_polled_device); 280 - 281 - /** 282 - * input_register_polled_device - register polled device 283 - * @dev: device to register 284 - * 285 - * The function registers previously initialized polled input device 286 - * with input layer. The device should be allocated with call to 287 - * input_allocate_polled_device(). Callers should also set up poll() 288 - * method and set up capabilities (id, name, phys, bits) of the 289 - * corresponding input_dev structure. 290 - */ 291 - int input_register_polled_device(struct input_polled_dev *dev) 292 - { 293 - struct input_polled_devres *devres = NULL; 294 - struct input_dev *input = dev->input; 295 - int error; 296 - 297 - if (dev->devres_managed) { 298 - devres = devres_alloc(devm_input_polldev_unregister, 299 - sizeof(*devres), GFP_KERNEL); 300 - if (!devres) 301 - return -ENOMEM; 302 - 303 - devres->polldev = dev; 304 - } 305 - 306 - input_set_drvdata(input, dev); 307 - INIT_DELAYED_WORK(&dev->work, input_polled_device_work); 308 - 309 - if (!dev->poll_interval) 310 - dev->poll_interval = 500; 311 - if (!dev->poll_interval_max) 312 - dev->poll_interval_max = dev->poll_interval; 313 - 314 - input->open = input_open_polled_device; 315 - input->close = input_close_polled_device; 316 - 317 - input->dev.groups = input_polldev_attribute_groups; 318 - 319 - error = input_register_device(input); 320 - if (error) { 321 - devres_free(devres); 322 - return error; 323 - } 324 - 325 - /* 326 - * Take extra reference to the underlying input device so 327 - * that it survives call to input_unregister_polled_device() 328 - * and is deleted only after input_free_polled_device() 329 - * has been invoked. This is needed to ease task of freeing 330 - * sparse keymaps. 331 - */ 332 - input_get_device(input); 333 - 334 - if (dev->devres_managed) { 335 - dev_dbg(input->dev.parent, "%s: registering %s with devres.\n", 336 - __func__, dev_name(&input->dev)); 337 - devres_add(input->dev.parent, devres); 338 - } 339 - 340 - return 0; 341 - } 342 - EXPORT_SYMBOL(input_register_polled_device); 343 - 344 - /** 345 - * input_unregister_polled_device - unregister polled device 346 - * @dev: device to unregister 347 - * 348 - * The function unregisters previously registered polled input 349 - * device from input layer. Polling is stopped and device is 350 - * ready to be freed with call to input_free_polled_device(). 351 - */ 352 - void input_unregister_polled_device(struct input_polled_dev *dev) 353 - { 354 - if (dev->devres_managed) 355 - WARN_ON(devres_destroy(dev->input->dev.parent, 356 - devm_input_polldev_unregister, 357 - devm_input_polldev_match, 358 - dev)); 359 - 360 - input_unregister_device(dev->input); 361 - } 362 - EXPORT_SYMBOL(input_unregister_polled_device);
+1 -1
drivers/input/input-poller.c
··· 166 166 167 167 poller->poll_interval = interval; 168 168 169 - if (input->users) { 169 + if (input_device_enabled(input)) { 170 170 cancel_delayed_work_sync(&poller->work); 171 171 if (poller->poll_interval > 0) 172 172 input_dev_poller_queue_work(poller);
+112 -6
drivers/input/input.c
··· 367 367 static void input_handle_event(struct input_dev *dev, 368 368 unsigned int type, unsigned int code, int value) 369 369 { 370 - int disposition = input_get_disposition(dev, type, code, &value); 370 + int disposition; 371 371 372 + /* filter-out events from inhibited devices */ 373 + if (dev->inhibited) 374 + return; 375 + 376 + disposition = input_get_disposition(dev, type, code, &value); 372 377 if (disposition != INPUT_IGNORE_EVENT && type != EV_SYN) 373 378 add_input_randomness(type, code, value); 374 379 ··· 617 612 618 613 handle->open++; 619 614 620 - if (dev->users++) { 615 + if (dev->users++ || dev->inhibited) { 621 616 /* 622 - * Device is already opened, so we can exit immediately and 623 - * report success. 617 + * Device is already opened and/or inhibited, 618 + * so we can exit immediately and report success. 624 619 */ 625 620 goto out; 626 621 } ··· 680 675 681 676 __input_release_device(handle); 682 677 683 - if (!--dev->users) { 678 + if (!dev->inhibited && !--dev->users) { 684 679 if (dev->poller) 685 680 input_dev_poller_stop(dev->poller); 686 - 687 681 if (dev->close) 688 682 dev->close(dev); 689 683 } ··· 1420 1416 } 1421 1417 static DEVICE_ATTR(properties, S_IRUGO, input_dev_show_properties, NULL); 1422 1418 1419 + static int input_inhibit_device(struct input_dev *dev); 1420 + static int input_uninhibit_device(struct input_dev *dev); 1421 + 1422 + static ssize_t inhibited_show(struct device *dev, 1423 + struct device_attribute *attr, 1424 + char *buf) 1425 + { 1426 + struct input_dev *input_dev = to_input_dev(dev); 1427 + 1428 + return scnprintf(buf, PAGE_SIZE, "%d\n", input_dev->inhibited); 1429 + } 1430 + 1431 + static ssize_t inhibited_store(struct device *dev, 1432 + struct device_attribute *attr, const char *buf, 1433 + size_t len) 1434 + { 1435 + struct input_dev *input_dev = to_input_dev(dev); 1436 + ssize_t rv; 1437 + bool inhibited; 1438 + 1439 + if (strtobool(buf, &inhibited)) 1440 + return -EINVAL; 1441 + 1442 + if (inhibited) 1443 + rv = input_inhibit_device(input_dev); 1444 + else 1445 + rv = input_uninhibit_device(input_dev); 1446 + 1447 + if (rv != 0) 1448 + return rv; 1449 + 1450 + return len; 1451 + } 1452 + 1453 + static DEVICE_ATTR_RW(inhibited); 1454 + 1423 1455 static struct attribute *input_dev_attrs[] = { 1424 1456 &dev_attr_name.attr, 1425 1457 &dev_attr_phys.attr, 1426 1458 &dev_attr_uniq.attr, 1427 1459 &dev_attr_modalias.attr, 1428 1460 &dev_attr_properties.attr, 1461 + &dev_attr_inhibited.attr, 1429 1462 NULL 1430 1463 }; 1431 1464 ··· 1743 1702 mutex_unlock(&dev->mutex); 1744 1703 } 1745 1704 EXPORT_SYMBOL(input_reset_device); 1705 + 1706 + static int input_inhibit_device(struct input_dev *dev) 1707 + { 1708 + int ret = 0; 1709 + 1710 + mutex_lock(&dev->mutex); 1711 + 1712 + if (dev->inhibited) 1713 + goto out; 1714 + 1715 + if (dev->users) { 1716 + if (dev->close) 1717 + dev->close(dev); 1718 + if (dev->poller) 1719 + input_dev_poller_stop(dev->poller); 1720 + } 1721 + 1722 + spin_lock_irq(&dev->event_lock); 1723 + input_dev_release_keys(dev); 1724 + input_dev_toggle(dev, false); 1725 + spin_unlock_irq(&dev->event_lock); 1726 + 1727 + dev->inhibited = true; 1728 + 1729 + out: 1730 + mutex_unlock(&dev->mutex); 1731 + return ret; 1732 + } 1733 + 1734 + static int input_uninhibit_device(struct input_dev *dev) 1735 + { 1736 + int ret = 0; 1737 + 1738 + mutex_lock(&dev->mutex); 1739 + 1740 + if (!dev->inhibited) 1741 + goto out; 1742 + 1743 + if (dev->users) { 1744 + if (dev->open) { 1745 + ret = dev->open(dev); 1746 + if (ret) 1747 + goto out; 1748 + } 1749 + if (dev->poller) 1750 + input_dev_poller_start(dev->poller); 1751 + } 1752 + 1753 + dev->inhibited = false; 1754 + spin_lock_irq(&dev->event_lock); 1755 + input_dev_toggle(dev, true); 1756 + spin_unlock_irq(&dev->event_lock); 1757 + 1758 + out: 1759 + mutex_unlock(&dev->mutex); 1760 + return ret; 1761 + } 1746 1762 1747 1763 #ifdef CONFIG_PM_SLEEP 1748 1764 static int input_dev_suspend(struct device *dev) ··· 2224 2126 dev->rep[REP_PERIOD] = period; 2225 2127 } 2226 2128 EXPORT_SYMBOL(input_enable_softrepeat); 2129 + 2130 + bool input_device_enabled(struct input_dev *dev) 2131 + { 2132 + lockdep_assert_held(&dev->mutex); 2133 + 2134 + return !dev->inhibited && dev->users > 0; 2135 + } 2136 + EXPORT_SYMBOL_GPL(input_device_enabled); 2227 2137 2228 2138 /** 2229 2139 * input_register_device - register device with input core
+1 -1
drivers/input/joystick/analog.c
··· 665 665 int err; 666 666 667 667 if (!(port = kzalloc(sizeof(struct analog_port), GFP_KERNEL))) 668 - return - ENOMEM; 668 + return -ENOMEM; 669 669 670 670 err = analog_init_port(gameport, drv, port); 671 671 if (err)
+3 -3
drivers/input/joystick/xpad.c
··· 1339 1339 struct usb_xpad *xpad; 1340 1340 }; 1341 1341 1342 - /** 1342 + /* 1343 1343 * set the LEDs on Xbox360 / Wireless Controllers 1344 1344 * @param command 1345 1345 * 0: off ··· 1904 1904 xpad360w_poweroff_controller(xpad); 1905 1905 } else { 1906 1906 mutex_lock(&input->mutex); 1907 - if (input->users) 1907 + if (input_device_enabled(input)) 1908 1908 xpad_stop_input(xpad); 1909 1909 mutex_unlock(&input->mutex); 1910 1910 } ··· 1924 1924 retval = xpad360w_start_input(xpad); 1925 1925 } else { 1926 1926 mutex_lock(&input->mutex); 1927 - if (input->users) { 1927 + if (input_device_enabled(input)) { 1928 1928 retval = xpad_start_input(xpad); 1929 1929 } else if (xpad->xtype == XTYPE_XBOXONE) { 1930 1930 /*
+1 -1
drivers/input/keyboard/Kconfig
··· 457 457 458 458 config KEYBOARD_IMX 459 459 tristate "IMX keypad support" 460 - depends on ARCH_MXC 460 + depends on ARCH_MXC || COMPILE_TEST 461 461 select INPUT_MATRIXKMAP 462 462 help 463 463 Enable support for IMX keypad port.
+71 -145
drivers/input/keyboard/adp5589-keys.c
··· 7 7 * Copyright (C) 2010-2011 Analog Devices Inc. 8 8 */ 9 9 10 + #include <linux/bitops.h> 10 11 #include <linux/module.h> 11 12 #include <linux/interrupt.h> 12 13 #include <linux/irq.h> 13 14 #include <linux/workqueue.h> 14 15 #include <linux/errno.h> 15 16 #include <linux/pm.h> 17 + #include <linux/pm_wakeirq.h> 16 18 #include <linux/platform_device.h> 17 19 #include <linux/input.h> 18 20 #include <linux/i2c.h> ··· 155 153 #define ADP5589_5_MAN_ID 0x02 156 154 157 155 /* GENERAL_CFG Register */ 158 - #define OSC_EN (1 << 7) 156 + #define OSC_EN BIT(7) 159 157 #define CORE_CLK(x) (((x) & 0x3) << 5) 160 - #define LCK_TRK_LOGIC (1 << 4) /* ADP5589 only */ 161 - #define LCK_TRK_GPI (1 << 3) /* ADP5589 only */ 162 - #define INT_CFG (1 << 1) 163 - #define RST_CFG (1 << 0) 158 + #define LCK_TRK_LOGIC BIT(4) /* ADP5589 only */ 159 + #define LCK_TRK_GPI BIT(3) /* ADP5589 only */ 160 + #define INT_CFG BIT(1) 161 + #define RST_CFG BIT(0) 164 162 165 163 /* INT_EN Register */ 166 - #define LOGIC2_IEN (1 << 5) /* ADP5589 only */ 167 - #define LOGIC1_IEN (1 << 4) 168 - #define LOCK_IEN (1 << 3) /* ADP5589 only */ 169 - #define OVRFLOW_IEN (1 << 2) 170 - #define GPI_IEN (1 << 1) 171 - #define EVENT_IEN (1 << 0) 164 + #define LOGIC2_IEN BIT(5) /* ADP5589 only */ 165 + #define LOGIC1_IEN BIT(4) 166 + #define LOCK_IEN BIT(3) /* ADP5589 only */ 167 + #define OVRFLOW_IEN BIT(2) 168 + #define GPI_IEN BIT(1) 169 + #define EVENT_IEN BIT(0) 172 170 173 171 /* Interrupt Status Register */ 174 - #define LOGIC2_INT (1 << 5) /* ADP5589 only */ 175 - #define LOGIC1_INT (1 << 4) 176 - #define LOCK_INT (1 << 3) /* ADP5589 only */ 177 - #define OVRFLOW_INT (1 << 2) 178 - #define GPI_INT (1 << 1) 179 - #define EVENT_INT (1 << 0) 172 + #define LOGIC2_INT BIT(5) /* ADP5589 only */ 173 + #define LOGIC1_INT BIT(4) 174 + #define LOCK_INT BIT(3) /* ADP5589 only */ 175 + #define OVRFLOW_INT BIT(2) 176 + #define GPI_INT BIT(1) 177 + #define EVENT_INT BIT(0) 180 178 181 179 /* STATUS Register */ 182 - #define LOGIC2_STAT (1 << 7) /* ADP5589 only */ 183 - #define LOGIC1_STAT (1 << 6) 184 - #define LOCK_STAT (1 << 5) /* ADP5589 only */ 180 + #define LOGIC2_STAT BIT(7) /* ADP5589 only */ 181 + #define LOGIC1_STAT BIT(6) 182 + #define LOCK_STAT BIT(5) /* ADP5589 only */ 185 183 #define KEC 0x1F 186 184 187 185 /* PIN_CONFIG_D Register */ 188 - #define C4_EXTEND_CFG (1 << 6) /* RESET2 */ 189 - #define R4_EXTEND_CFG (1 << 5) /* RESET1 */ 186 + #define C4_EXTEND_CFG BIT(6) /* RESET2 */ 187 + #define R4_EXTEND_CFG BIT(5) /* RESET1 */ 190 188 191 189 /* LOCK_CFG */ 192 - #define LOCK_EN (1 << 0) 190 + #define LOCK_EN BIT(0) 193 191 194 192 #define PTIME_MASK 0x3 195 193 #define LTIME_MASK 0x3 /* ADP5589 only */ 196 194 197 195 /* Key Event Register xy */ 198 - #define KEY_EV_PRESSED (1 << 7) 199 - #define KEY_EV_MASK (0x7F) 196 + #define KEY_EV_PRESSED BIT(7) 197 + #define KEY_EV_MASK 0x7F 200 198 201 199 #define KEYP_MAX_EVENT 16 202 200 #define ADP5589_MAXGPIO 19 ··· 240 238 bool support_row5; 241 239 #ifdef CONFIG_GPIOLIB 242 240 unsigned char gpiomap[ADP5589_MAXGPIO]; 243 - bool export_gpio; 244 241 struct gpio_chip gc; 245 242 struct mutex gpio_lock; /* Protect cached dir, dat_out */ 246 243 u8 dat_out[3]; ··· 474 473 memset(pin_used, false, sizeof(pin_used)); 475 474 476 475 for (i = 0; i < kpad->var->maxgpio; i++) 477 - if (pdata->keypad_en_mask & (1 << i)) 476 + if (pdata->keypad_en_mask & BIT(i)) 478 477 pin_used[i] = true; 479 478 480 479 for (i = 0; i < kpad->gpimapsize; i++) ··· 513 512 return 0; 514 513 } 515 514 516 - kpad->export_gpio = true; 517 - 518 515 kpad->gc.direction_input = adp5589_gpio_direction_input; 519 516 kpad->gc.direction_output = adp5589_gpio_direction_output; 520 517 kpad->gc.get = adp5589_gpio_get_value; ··· 525 526 526 527 mutex_init(&kpad->gpio_lock); 527 528 528 - error = gpiochip_add_data(&kpad->gc, kpad); 529 - if (error) { 530 - dev_err(dev, "gpiochip_add_data() failed, err: %d\n", error); 529 + error = devm_gpiochip_add_data(dev, &kpad->gc, kpad); 530 + if (error) 531 531 return error; 532 - } 533 532 534 533 for (i = 0; i <= kpad->var->bank(kpad->var->maxgpio); i++) { 535 534 kpad->dat_out[i] = adp5589_read(kpad->client, kpad->var->reg( ··· 536 539 ADP5589_GPIO_DIRECTION_A) + i); 537 540 } 538 541 539 - if (gpio_data->setup) { 540 - error = gpio_data->setup(kpad->client, 541 - kpad->gc.base, kpad->gc.ngpio, 542 - gpio_data->context); 543 - if (error) 544 - dev_warn(dev, "setup failed, %d\n", error); 545 - } 546 - 547 542 return 0; 548 - } 549 - 550 - static void adp5589_gpio_remove(struct adp5589_kpad *kpad) 551 - { 552 - struct device *dev = &kpad->client->dev; 553 - const struct adp5589_kpad_platform_data *pdata = dev_get_platdata(dev); 554 - const struct adp5589_gpio_platform_data *gpio_data = pdata->gpio_data; 555 - int error; 556 - 557 - if (!kpad->export_gpio) 558 - return; 559 - 560 - if (gpio_data->teardown) { 561 - error = gpio_data->teardown(kpad->client, 562 - kpad->gc.base, kpad->gc.ngpio, 563 - gpio_data->context); 564 - if (error) 565 - dev_warn(dev, "teardown failed %d\n", error); 566 - } 567 - 568 - gpiochip_remove(&kpad->gc); 569 543 } 570 544 #else 571 545 static inline int adp5589_gpio_add(struct adp5589_kpad *kpad) 572 546 { 573 547 return 0; 574 - } 575 - 576 - static inline void adp5589_gpio_remove(struct adp5589_kpad *kpad) 577 - { 578 548 } 579 549 #endif 580 550 ··· 653 689 unsigned short pin = pdata->gpimap[i].pin; 654 690 655 691 if (pin <= kpad->var->gpi_pin_row_end) { 656 - evt_mode1 |= (1 << (pin - kpad->var->gpi_pin_row_base)); 692 + evt_mode1 |= BIT(pin - kpad->var->gpi_pin_row_base); 657 693 } else { 658 694 evt_mode2 |= 659 - ((1 << (pin - kpad->var->gpi_pin_col_base)) & 0xFF); 695 + BIT(pin - kpad->var->gpi_pin_col_base) & 0xFF; 660 696 if (!kpad->is_adp5585) 661 - evt_mode3 |= ((1 << (pin - 662 - kpad->var->gpi_pin_col_base)) >> 8); 697 + evt_mode3 |= 698 + BIT(pin - kpad->var->gpi_pin_col_base) >> 8; 663 699 } 664 700 } 665 701 ··· 679 715 dev_warn(&client->dev, "Conflicting pull resistor config\n"); 680 716 681 717 for (i = 0; i <= kpad->var->max_row_num; i++) { 682 - unsigned val = 0, bit = (1 << i); 718 + unsigned int val = 0, bit = BIT(i); 683 719 if (pdata->pullup_en_300k & bit) 684 720 val = 0; 685 721 else if (pdata->pulldown_en_300k & bit) ··· 699 735 } 700 736 701 737 for (i = 0; i <= kpad->var->max_col_num; i++) { 702 - unsigned val = 0, bit = 1 << (i + kpad->var->col_shift); 738 + unsigned int val = 0, bit = BIT(i + kpad->var->col_shift); 703 739 if (pdata->pullup_en_300k & bit) 704 740 val = 0; 705 741 else if (pdata->pulldown_en_300k & bit) ··· 815 851 816 852 input_report_switch(kpad->input, 817 853 kpad->gpimap[i].sw_evt, 818 - !(gpi_stat_tmp & (1 << pin_loc))); 854 + !(gpi_stat_tmp & BIT(pin_loc))); 819 855 } 820 856 821 857 input_sync(kpad->input); ··· 861 897 return -EINVAL; 862 898 } 863 899 864 - if ((1 << (pin - kpad->var->gpi_pin_row_base)) & 900 + if (BIT(pin - kpad->var->gpi_pin_row_base) & 865 901 pdata->keypad_en_mask) { 866 902 dev_err(&client->dev, "invalid gpi row/col data\n"); 867 903 return -EINVAL; ··· 873 909 return -EINVAL; 874 910 } 875 911 876 - input = input_allocate_device(); 912 + input = devm_input_allocate_device(&client->dev); 877 913 if (!input) 878 914 return -ENOMEM; 879 915 ··· 919 955 error = input_register_device(input); 920 956 if (error) { 921 957 dev_err(&client->dev, "unable to register input device\n"); 922 - goto err_free_input; 958 + return error; 923 959 } 924 960 925 - error = request_threaded_irq(client->irq, NULL, adp5589_irq, 926 - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 927 - client->dev.driver->name, kpad); 961 + error = devm_request_threaded_irq(&client->dev, client->irq, 962 + NULL, adp5589_irq, 963 + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 964 + client->dev.driver->name, kpad); 928 965 if (error) { 929 - dev_err(&client->dev, "irq %d busy?\n", client->irq); 930 - goto err_unreg_dev; 966 + dev_err(&client->dev, "unable to request irq %d\n", client->irq); 967 + return error; 931 968 } 932 - 933 - device_init_wakeup(&client->dev, 1); 934 969 935 970 return 0; 936 - 937 - err_unreg_dev: 938 - input_unregister_device(input); 939 - input = NULL; 940 - err_free_input: 941 - input_free_device(input); 942 - 943 - return error; 944 971 } 945 972 946 - static void adp5589_keypad_remove(struct adp5589_kpad *kpad) 973 + static void adp5589_clear_config(void *data) 947 974 { 948 - if (kpad->input) { 949 - free_irq(kpad->client->irq, kpad); 950 - input_unregister_device(kpad->input); 951 - } 975 + struct i2c_client *client = data; 976 + struct adp5589_kpad *kpad = i2c_get_clientdata(client); 977 + 978 + adp5589_write(client, kpad->var->reg(ADP5589_GENERAL_CFG), 0); 952 979 } 953 980 954 981 static int adp5589_probe(struct i2c_client *client, ··· 962 1007 return -EINVAL; 963 1008 } 964 1009 965 - kpad = kzalloc(sizeof(*kpad), GFP_KERNEL); 1010 + kpad = devm_kzalloc(&client->dev, sizeof(*kpad), GFP_KERNEL); 966 1011 if (!kpad) 967 1012 return -ENOMEM; 968 1013 ··· 982 1027 break; 983 1028 } 984 1029 1030 + error = devm_add_action_or_reset(&client->dev, adp5589_clear_config, 1031 + client); 1032 + if (error) 1033 + return error; 1034 + 985 1035 ret = adp5589_read(client, ADP5589_5_ID); 986 - if (ret < 0) { 987 - error = ret; 988 - goto err_free_mem; 989 - } 1036 + if (ret < 0) 1037 + return ret; 990 1038 991 1039 revid = (u8) ret & ADP5589_5_DEVICE_ID_MASK; 992 1040 993 1041 if (pdata->keymapsize) { 994 1042 error = adp5589_keypad_add(kpad, revid); 995 1043 if (error) 996 - goto err_free_mem; 1044 + return error; 997 1045 } 998 1046 999 1047 error = adp5589_setup(kpad); 1000 1048 if (error) 1001 - goto err_keypad_remove; 1049 + return error; 1002 1050 1003 1051 if (kpad->gpimapsize) 1004 1052 adp5589_report_switch_state(kpad); 1005 1053 1006 1054 error = adp5589_gpio_add(kpad); 1007 1055 if (error) 1008 - goto err_keypad_remove; 1056 + return error; 1009 1057 1010 1058 i2c_set_clientdata(client, kpad); 1011 1059 1012 1060 dev_info(&client->dev, "Rev.%d keypad, irq %d\n", revid, client->irq); 1013 1061 return 0; 1014 - 1015 - err_keypad_remove: 1016 - adp5589_keypad_remove(kpad); 1017 - err_free_mem: 1018 - kfree(kpad); 1019 - 1020 - return error; 1021 1062 } 1022 1063 1023 - static int adp5589_remove(struct i2c_client *client) 1064 + static int __maybe_unused adp5589_suspend(struct device *dev) 1024 1065 { 1066 + struct i2c_client *client = to_i2c_client(dev); 1025 1067 struct adp5589_kpad *kpad = i2c_get_clientdata(client); 1026 1068 1027 - adp5589_write(client, kpad->var->reg(ADP5589_GENERAL_CFG), 0); 1028 - adp5589_keypad_remove(kpad); 1029 - adp5589_gpio_remove(kpad); 1030 - kfree(kpad); 1069 + if (kpad->input) 1070 + disable_irq(client->irq); 1031 1071 1032 1072 return 0; 1033 1073 } 1034 1074 1035 - #ifdef CONFIG_PM_SLEEP 1036 - static int adp5589_suspend(struct device *dev) 1075 + static int __maybe_unused adp5589_resume(struct device *dev) 1037 1076 { 1038 - struct adp5589_kpad *kpad = dev_get_drvdata(dev); 1039 - struct i2c_client *client = kpad->client; 1077 + struct i2c_client *client = to_i2c_client(dev); 1078 + struct adp5589_kpad *kpad = i2c_get_clientdata(client); 1040 1079 1041 - if (!kpad->input) 1042 - return 0; 1043 - 1044 - disable_irq(client->irq); 1045 - 1046 - if (device_may_wakeup(&client->dev)) 1047 - enable_irq_wake(client->irq); 1080 + if (kpad->input) 1081 + enable_irq(client->irq); 1048 1082 1049 1083 return 0; 1050 1084 } 1051 - 1052 - static int adp5589_resume(struct device *dev) 1053 - { 1054 - struct adp5589_kpad *kpad = dev_get_drvdata(dev); 1055 - struct i2c_client *client = kpad->client; 1056 - 1057 - if (!kpad->input) 1058 - return 0; 1059 - 1060 - if (device_may_wakeup(&client->dev)) 1061 - disable_irq_wake(client->irq); 1062 - 1063 - enable_irq(client->irq); 1064 - 1065 - return 0; 1066 - } 1067 - #endif 1068 1085 1069 1086 static SIMPLE_DEV_PM_OPS(adp5589_dev_pm_ops, adp5589_suspend, adp5589_resume); 1070 1087 ··· 1055 1128 .pm = &adp5589_dev_pm_ops, 1056 1129 }, 1057 1130 .probe = adp5589_probe, 1058 - .remove = adp5589_remove, 1059 1131 .id_table = adp5589_id, 1060 1132 }; 1061 1133
+17 -4
drivers/input/keyboard/applespi.c
··· 286 286 * structure (after re-assembly in case of being split over 287 287 * multiple spi-packets), minus the trailing crc. The total size 288 288 * of the message struct is therefore @length + 10. 289 + * 290 + * @keyboard: Keyboard message 291 + * @touchpad: Touchpad message 292 + * @tp_info: Touchpad info (response) 293 + * @tp_info_command: Touchpad info (CRC) 294 + * @init_mt_command: Initialise Multitouch 295 + * @capsl_command: Toggle caps-lock LED 296 + * @bl_command: Keyboard brightness 297 + * @data: Buffer data 289 298 */ 290 299 struct message { 291 300 __le16 type; ··· 554 545 memset(dl_t, 0, sizeof(*dl_t)); 555 546 memset(rd_t, 0, sizeof(*rd_t)); 556 547 557 - dl_t->delay_usecs = applespi->spi_settings.spi_cs_delay; 548 + dl_t->delay.value = applespi->spi_settings.spi_cs_delay; 549 + dl_t->delay.unit = SPI_DELAY_UNIT_USECS; 558 550 559 551 rd_t->rx_buf = applespi->rx_buffer; 560 552 rd_t->len = APPLESPI_PACKET_SIZE; ··· 584 574 * end up with an extra unnecessary (but harmless) cs assertion and 585 575 * deassertion. 586 576 */ 587 - wt_t->delay_usecs = SPI_RW_CHG_DELAY_US; 577 + wt_t->delay.value = SPI_RW_CHG_DELAY_US; 578 + wt_t->delay.unit = SPI_DELAY_UNIT_USECS; 588 579 wt_t->cs_change = 1; 589 580 590 - dl_t->delay_usecs = applespi->spi_settings.spi_cs_delay; 581 + dl_t->delay.value = applespi->spi_settings.spi_cs_delay; 582 + dl_t->delay.unit = SPI_DELAY_UNIT_USECS; 591 583 592 584 wr_t->tx_buf = applespi->tx_buffer; 593 585 wr_t->len = APPLESPI_PACKET_SIZE; 594 - wr_t->delay_usecs = SPI_RW_CHG_DELAY_US; 586 + wr_t->delay.value = SPI_RW_CHG_DELAY_US; 587 + wr_t->delay.unit = SPI_DELAY_UNIT_USECS; 595 588 596 589 st_t->rx_buf = applespi->tx_status; 597 590 st_t->len = APPLESPI_STATUS_SIZE;
+5 -4
drivers/input/keyboard/cros_ec_keyb.c
··· 27 27 28 28 #include <asm/unaligned.h> 29 29 30 - /* 30 + /** 31 + * struct cros_ec_keyb - Structure representing EC keyboard device 32 + * 31 33 * @rows: Number of rows in the keypad 32 34 * @cols: Number of columns in the keypad 33 35 * @row_shift: log2 or number of rows, rounded up ··· 60 58 struct notifier_block notifier; 61 59 }; 62 60 63 - 64 61 /** 65 - * cros_ec_bs_map - Struct mapping Linux keycodes to EC button/switch bitmap 66 - * #defines 62 + * struct cros_ec_bs_map - Mapping between Linux keycodes and EC button/switch 63 + * bitmap #defines 67 64 * 68 65 * @ev_type: The type of the input event to generate (e.g., EV_KEY). 69 66 * @code: A linux keycode
+1 -1
drivers/input/keyboard/ep93xx_keypad.c
··· 208 208 209 209 mutex_lock(&input_dev->mutex); 210 210 211 - if (input_dev->users) { 211 + if (input_device_enabled(input_dev)) { 212 212 if (!keypad->enabled) { 213 213 ep93xx_keypad_config(keypad); 214 214 clk_enable(keypad->clk);
+3 -3
drivers/input/keyboard/gpio_keys.c
··· 108 108 109 109 /** 110 110 * get_bm_events_by_type() - returns bitmap of supported events per @type 111 - * @input: input device from which bitmap is retrieved 111 + * @dev: input device from which bitmap is retrieved 112 112 * @type: type of button (%EV_KEY, %EV_SW) 113 113 * 114 114 * Return value of this function can be used to allocate bitmap ··· 965 965 return error; 966 966 } else { 967 967 mutex_lock(&input->mutex); 968 - if (input->users) 968 + if (input_device_enabled(input)) 969 969 gpio_keys_close(input); 970 970 mutex_unlock(&input->mutex); 971 971 } ··· 983 983 gpio_keys_disable_wakeup(ddata); 984 984 } else { 985 985 mutex_lock(&input->mutex); 986 - if (input->users) 986 + if (input_device_enabled(input)) 987 987 error = gpio_keys_open(input); 988 988 mutex_unlock(&input->mutex); 989 989 }
+2 -2
drivers/input/keyboard/imx_keypad.c
··· 532 532 /* imx kbd can wake up system even clock is disabled */ 533 533 mutex_lock(&input_dev->mutex); 534 534 535 - if (input_dev->users) 535 + if (input_device_enabled(input_dev)) 536 536 clk_disable_unprepare(kbd->clk); 537 537 538 538 mutex_unlock(&input_dev->mutex); ··· 562 562 563 563 mutex_lock(&input_dev->mutex); 564 564 565 - if (input_dev->users) { 565 + if (input_device_enabled(input_dev)) { 566 566 ret = clk_prepare_enable(kbd->clk); 567 567 if (ret) 568 568 goto err_clk;
+1 -1
drivers/input/keyboard/ipaq-micro-keys.c
··· 140 140 141 141 mutex_lock(&input->mutex); 142 142 143 - if (input->users) 143 + if (input_device_enabled(input)) 144 144 micro_key_start(keys); 145 145 146 146 mutex_unlock(&input->mutex);
+2 -2
drivers/input/keyboard/lpc32xx-keys.c
··· 273 273 274 274 mutex_lock(&input->mutex); 275 275 276 - if (input->users) { 276 + if (input_device_enabled(input)) { 277 277 /* Clear IRQ and disable clock */ 278 278 writel(1, LPC32XX_KS_IRQ(kscandat->kscan_base)); 279 279 clk_disable_unprepare(kscandat->clk); ··· 292 292 293 293 mutex_lock(&input->mutex); 294 294 295 - if (input->users) { 295 + if (input_device_enabled(input)) { 296 296 /* Enable clock and clear IRQ */ 297 297 retval = clk_prepare_enable(kscandat->clk); 298 298 if (retval == 0)
+2
drivers/input/keyboard/nomadik-ske-keypad.c
··· 58 58 * @board: keypad platform device 59 59 * @keymap: matrix scan code table for keycodes 60 60 * @clk: clock structure pointer 61 + * @pclk: clock structure pointer 62 + * @ske_keypad_lock: spinlock protecting the keypad read/writes 61 63 */ 62 64 struct ske_keypad { 63 65 int irq;
+61 -71
drivers/input/keyboard/omap4-keypad.c
··· 18 18 #include <linux/input/matrix_keypad.h> 19 19 #include <linux/slab.h> 20 20 #include <linux/pm_runtime.h> 21 + #include <linux/pm_wakeirq.h> 21 22 22 23 /* OMAP4 registers */ 23 24 #define OMAP4_KBD_REVISION 0x00 ··· 70 69 struct input_dev *input; 71 70 72 71 void __iomem *base; 73 - bool irq_wake_enabled; 74 72 unsigned int irq; 75 73 76 74 unsigned int rows; ··· 186 186 return 0; 187 187 } 188 188 189 - static void omap4_keypad_close(struct input_dev *input) 189 + static void omap4_keypad_stop(struct omap4_keypad *keypad_data) 190 190 { 191 - struct omap4_keypad *keypad_data = input_get_drvdata(input); 192 - 193 - disable_irq(keypad_data->irq); 194 - 195 191 /* Disable interrupts and wake-up events */ 196 192 kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE, 197 193 OMAP4_VAL_IRQDISABLE); ··· 196 200 /* clear pending interrupts */ 197 201 kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS, 198 202 kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS)); 203 + } 199 204 205 + static void omap4_keypad_close(struct input_dev *input) 206 + { 207 + struct omap4_keypad *keypad_data; 208 + 209 + keypad_data = input_get_drvdata(input); 210 + disable_irq(keypad_data->irq); 211 + omap4_keypad_stop(keypad_data); 200 212 enable_irq(keypad_data->irq); 201 213 202 214 pm_runtime_put_sync(input->dev.parent); ··· 227 223 return 0; 228 224 } 229 225 226 + static int omap4_keypad_check_revision(struct device *dev, 227 + struct omap4_keypad *keypad_data) 228 + { 229 + unsigned int rev; 230 + 231 + rev = __raw_readl(keypad_data->base + OMAP4_KBD_REVISION); 232 + rev &= 0x03 << 30; 233 + rev >>= 30; 234 + switch (rev) { 235 + case KBD_REVISION_OMAP4: 236 + keypad_data->reg_offset = 0x00; 237 + keypad_data->irqreg_offset = 0x00; 238 + break; 239 + case KBD_REVISION_OMAP5: 240 + keypad_data->reg_offset = 0x10; 241 + keypad_data->irqreg_offset = 0x0c; 242 + break; 243 + default: 244 + dev_err(dev, "Keypad reports unsupported revision %d", rev); 245 + return -EINVAL; 246 + } 247 + 248 + return 0; 249 + } 250 + 230 251 static int omap4_keypad_probe(struct platform_device *pdev) 231 252 { 232 253 struct omap4_keypad *keypad_data; 233 254 struct input_dev *input_dev; 234 255 struct resource *res; 235 256 unsigned int max_keys; 236 - int rev; 237 257 int irq; 238 258 int error; 239 259 ··· 297 269 goto err_release_mem; 298 270 } 299 271 272 + pm_runtime_enable(&pdev->dev); 300 273 301 274 /* 302 275 * Enable clocks for the keypad module so that we can read 303 276 * revision register. 304 277 */ 305 - pm_runtime_enable(&pdev->dev); 306 278 error = pm_runtime_get_sync(&pdev->dev); 307 279 if (error) { 308 280 dev_err(&pdev->dev, "pm_runtime_get_sync() failed\n"); 309 - goto err_unmap; 281 + pm_runtime_put_noidle(&pdev->dev); 282 + } else { 283 + error = omap4_keypad_check_revision(&pdev->dev, 284 + keypad_data); 285 + if (!error) { 286 + /* Ensure device does not raise interrupts */ 287 + omap4_keypad_stop(keypad_data); 288 + } 289 + pm_runtime_put_sync(&pdev->dev); 310 290 } 311 - rev = __raw_readl(keypad_data->base + OMAP4_KBD_REVISION); 312 - rev &= 0x03 << 30; 313 - rev >>= 30; 314 - switch (rev) { 315 - case KBD_REVISION_OMAP4: 316 - keypad_data->reg_offset = 0x00; 317 - keypad_data->irqreg_offset = 0x00; 318 - break; 319 - case KBD_REVISION_OMAP5: 320 - keypad_data->reg_offset = 0x10; 321 - keypad_data->irqreg_offset = 0x0c; 322 - break; 323 - default: 324 - dev_err(&pdev->dev, 325 - "Keypad reports unsupported revision %d", rev); 326 - error = -EINVAL; 327 - goto err_pm_put_sync; 328 - } 291 + if (error) 292 + goto err_pm_disable; 329 293 330 294 /* input device allocation */ 331 295 keypad_data->input = input_dev = input_allocate_device(); 332 296 if (!input_dev) { 333 297 error = -ENOMEM; 334 - goto err_pm_put_sync; 298 + goto err_pm_disable; 335 299 } 336 300 337 301 input_dev->name = pdev->name; ··· 369 349 goto err_free_keymap; 370 350 } 371 351 372 - device_init_wakeup(&pdev->dev, true); 373 - pm_runtime_put_sync(&pdev->dev); 374 - 375 352 error = input_register_device(keypad_data->input); 376 353 if (error < 0) { 377 354 dev_err(&pdev->dev, "failed to register input device\n"); 378 - goto err_pm_disable; 355 + goto err_free_irq; 379 356 } 380 357 358 + device_init_wakeup(&pdev->dev, true); 359 + error = dev_pm_set_wake_irq(&pdev->dev, keypad_data->irq); 360 + if (error) 361 + dev_warn(&pdev->dev, 362 + "failed to set up wakeup irq: %d\n", error); 363 + 381 364 platform_set_drvdata(pdev, keypad_data); 365 + 382 366 return 0; 383 367 384 - err_pm_disable: 385 - pm_runtime_disable(&pdev->dev); 368 + err_free_irq: 386 369 free_irq(keypad_data->irq, keypad_data); 387 370 err_free_keymap: 388 371 kfree(keypad_data->keymap); 389 372 err_free_input: 390 373 input_free_device(input_dev); 391 - err_pm_put_sync: 392 - pm_runtime_put_sync(&pdev->dev); 393 - err_unmap: 374 + err_pm_disable: 375 + pm_runtime_disable(&pdev->dev); 394 376 iounmap(keypad_data->base); 395 377 err_release_mem: 396 378 release_mem_region(res->start, resource_size(res)); ··· 405 383 { 406 384 struct omap4_keypad *keypad_data = platform_get_drvdata(pdev); 407 385 struct resource *res; 386 + 387 + dev_pm_clear_wake_irq(&pdev->dev); 408 388 409 389 free_irq(keypad_data->irq, keypad_data); 410 390 ··· 431 407 }; 432 408 MODULE_DEVICE_TABLE(of, omap_keypad_dt_match); 433 409 434 - #ifdef CONFIG_PM_SLEEP 435 - static int omap4_keypad_suspend(struct device *dev) 436 - { 437 - struct platform_device *pdev = to_platform_device(dev); 438 - struct omap4_keypad *keypad_data = platform_get_drvdata(pdev); 439 - int error; 440 - 441 - if (device_may_wakeup(&pdev->dev)) { 442 - error = enable_irq_wake(keypad_data->irq); 443 - if (!error) 444 - keypad_data->irq_wake_enabled = true; 445 - } 446 - 447 - return 0; 448 - } 449 - 450 - static int omap4_keypad_resume(struct device *dev) 451 - { 452 - struct platform_device *pdev = to_platform_device(dev); 453 - struct omap4_keypad *keypad_data = platform_get_drvdata(pdev); 454 - 455 - if (device_may_wakeup(&pdev->dev) && keypad_data->irq_wake_enabled) { 456 - disable_irq_wake(keypad_data->irq); 457 - keypad_data->irq_wake_enabled = false; 458 - } 459 - 460 - return 0; 461 - } 462 - #endif 463 - 464 - static SIMPLE_DEV_PM_OPS(omap4_keypad_pm_ops, 465 - omap4_keypad_suspend, omap4_keypad_resume); 466 - 467 410 static struct platform_driver omap4_keypad_driver = { 468 411 .probe = omap4_keypad_probe, 469 412 .remove = omap4_keypad_remove, 470 413 .driver = { 471 414 .name = "omap4-keypad", 472 - .pm = &omap4_keypad_pm_ops, 473 415 .of_match_table = omap_keypad_dt_match, 474 416 }, 475 417 };
+13 -13
drivers/input/keyboard/pmic8xxx-keypad.c
··· 76 76 77 77 /** 78 78 * struct pmic8xxx_kp - internal keypad data structure 79 - * @num_cols - number of columns of keypad 80 - * @num_rows - number of row of keypad 81 - * @input - input device pointer for keypad 82 - * @regmap - regmap handle 83 - * @key_sense_irq - key press/release irq number 84 - * @key_stuck_irq - key stuck notification irq number 85 - * @keycodes - array to hold the key codes 86 - * @dev - parent device pointer 87 - * @keystate - present key press/release state 88 - * @stuckstate - present state when key stuck irq 89 - * @ctrl_reg - control register value 79 + * @num_cols: number of columns of keypad 80 + * @num_rows: number of row of keypad 81 + * @input: input device pointer for keypad 82 + * @regmap: regmap handle 83 + * @key_sense_irq: key press/release irq number 84 + * @key_stuck_irq: key stuck notification irq number 85 + * @keycodes: array to hold the key codes 86 + * @dev: parent device pointer 87 + * @keystate: present key press/release state 88 + * @stuckstate: present state when key stuck irq 89 + * @ctrl_reg: control register value 90 90 */ 91 91 struct pmic8xxx_kp { 92 92 unsigned int num_rows; ··· 633 633 } else { 634 634 mutex_lock(&input_dev->mutex); 635 635 636 - if (input_dev->users) 636 + if (input_device_enabled(input_dev)) 637 637 pmic8xxx_kp_disable(kp); 638 638 639 639 mutex_unlock(&input_dev->mutex); ··· 653 653 } else { 654 654 mutex_lock(&input_dev->mutex); 655 655 656 - if (input_dev->users) 656 + if (input_device_enabled(input_dev)) 657 657 pmic8xxx_kp_enable(kp); 658 658 659 659 mutex_unlock(&input_dev->mutex);
+1 -1
drivers/input/keyboard/pxa27x_keypad.c
··· 694 694 } else { 695 695 mutex_lock(&input_dev->mutex); 696 696 697 - if (input_dev->users) { 697 + if (input_device_enabled(input_dev)) { 698 698 /* Enable unit clock */ 699 699 ret = clk_prepare_enable(keypad->clk); 700 700 if (!ret)
+3 -4
drivers/input/keyboard/samsung-keypad.c
··· 146 146 { 147 147 struct samsung_keypad *keypad = dev_id; 148 148 unsigned int row_state[SAMSUNG_MAX_COLS]; 149 - unsigned int val; 150 149 bool key_down; 151 150 152 151 pm_runtime_get_sync(&keypad->pdev->dev); 153 152 154 153 do { 155 - val = readl(keypad->base + SAMSUNG_KEYIFSTSCLR); 154 + readl(keypad->base + SAMSUNG_KEYIFSTSCLR); 156 155 /* Clear interrupt. */ 157 156 writel(~0x0, keypad->base + SAMSUNG_KEYIFSTSCLR); 158 157 ··· 536 537 537 538 mutex_lock(&input_dev->mutex); 538 539 539 - if (input_dev->users) 540 + if (input_device_enabled(input_dev)) 540 541 samsung_keypad_stop(keypad); 541 542 542 543 samsung_keypad_toggle_wakeup(keypad, true); ··· 556 557 557 558 samsung_keypad_toggle_wakeup(keypad, false); 558 559 559 - if (input_dev->users) 560 + if (input_device_enabled(input_dev)) 560 561 samsung_keypad_start(keypad); 561 562 562 563 mutex_unlock(&input_dev->mutex);
+4 -4
drivers/input/keyboard/spear-keyboard.c
··· 318 318 writel_relaxed(val, kbd->io_base + MODE_CTL_REG); 319 319 320 320 } else { 321 - if (input_dev->users) { 321 + if (input_device_enabled(input_dev)) { 322 322 writel_relaxed(mode_ctl_reg & ~MODE_CTL_START_SCAN, 323 323 kbd->io_base + MODE_CTL_REG); 324 324 clk_disable(kbd->clk); ··· 326 326 } 327 327 328 328 /* store current configuration */ 329 - if (input_dev->users) 329 + if (input_device_enabled(input_dev)) 330 330 kbd->mode_ctl_reg = mode_ctl_reg; 331 331 332 332 /* restore previous clk state */ ··· 351 351 disable_irq_wake(kbd->irq); 352 352 } 353 353 } else { 354 - if (input_dev->users) 354 + if (input_device_enabled(input_dev)) 355 355 clk_enable(kbd->clk); 356 356 } 357 357 358 358 /* restore current configuration */ 359 - if (input_dev->users) 359 + if (input_device_enabled(input_dev)) 360 360 writel_relaxed(kbd->mode_ctl_reg, kbd->io_base + MODE_CTL_REG); 361 361 362 362 mutex_unlock(&input_dev->mutex);
+2 -2
drivers/input/keyboard/st-keyscan.c
··· 221 221 222 222 if (device_may_wakeup(dev)) 223 223 enable_irq_wake(keypad->irq); 224 - else if (input->users) 224 + else if (input_device_enabled(input)) 225 225 keyscan_stop(keypad); 226 226 227 227 mutex_unlock(&input->mutex); ··· 239 239 240 240 if (device_may_wakeup(dev)) 241 241 disable_irq_wake(keypad->irq); 242 - else if (input->users) 242 + else if (input_device_enabled(input)) 243 243 retval = keyscan_start(keypad); 244 244 245 245 mutex_unlock(&input->mutex);
+2 -2
drivers/input/keyboard/tegra-kbc.c
··· 756 756 enable_irq(kbc->irq); 757 757 enable_irq_wake(kbc->irq); 758 758 } else { 759 - if (kbc->idev->users) 759 + if (input_device_enabled(kbc->idev)) 760 760 tegra_kbc_stop(kbc); 761 761 } 762 762 mutex_unlock(&kbc->idev->mutex); ··· 796 796 input_sync(kbc->idev); 797 797 } 798 798 } else { 799 - if (kbc->idev->users) 799 + if (input_device_enabled(kbc->idev)) 800 800 err = tegra_kbc_start(kbc); 801 801 } 802 802 mutex_unlock(&kbc->idev->mutex);
+2 -1
drivers/input/keyboard/tm2-touchkey.c
··· 48 48 struct input_dev *input_dev; 49 49 struct led_classdev led_dev; 50 50 struct regulator *vdd; 51 - struct regulator_bulk_data regulators[2]; 51 + struct regulator_bulk_data regulators[3]; 52 52 const struct touchkey_variant *variant; 53 53 u32 keycodes[4]; 54 54 int num_keycodes; ··· 204 204 205 205 touchkey->regulators[0].supply = "vcc"; 206 206 touchkey->regulators[1].supply = "vdd"; 207 + touchkey->regulators[2].supply = "vddio"; 207 208 error = devm_regulator_bulk_get(&client->dev, 208 209 ARRAY_SIZE(touchkey->regulators), 209 210 touchkey->regulators);
+23
drivers/input/misc/Kconfig
··· 73 73 To compile this driver as a module, choose M here: the 74 74 module will be called ad714x-spi. 75 75 76 + config INPUT_ARIEL_PWRBUTTON 77 + tristate "Dell Wyse 3020 Power Button Driver" 78 + depends on SPI 79 + depends on MACH_MMP3_DT || COMPILE_TEST 80 + help 81 + Say Y to enable support for reporting power button status on 82 + on Dell Wyse 3020 ("Ariel") thin client. 83 + 84 + To compile this driver as a module, choose M here: the module 85 + will be called ariel-pwrbutton. 86 + 76 87 config INPUT_ARIZONA_HAPTICS 77 88 tristate "Arizona haptics support" 78 89 depends on MFD_ARIZONA && SND_SOC ··· 619 608 620 609 To compile this driver as a module, choose M here: the 621 610 module will be called rb532_button. 611 + 612 + config INPUT_DA7280_HAPTICS 613 + tristate "Dialog Semiconductor DA7280 haptics support" 614 + depends on INPUT && I2C 615 + select REGMAP_I2C 616 + help 617 + Say Y to enable support for the Dialog DA7280 haptics driver. 618 + The haptics can be controlled by PWM or GPIO 619 + with I2C communication. 620 + 621 + To compile this driver as a module, choose M here: the 622 + module will be called da7280. 622 623 623 624 config INPUT_DA9052_ONKEY 624 625 tristate "Dialog DA9052/DA9053 Onkey"
+2
drivers/input/misc/Makefile
··· 15 15 obj-$(CONFIG_INPUT_ADXL34X_I2C) += adxl34x-i2c.o 16 16 obj-$(CONFIG_INPUT_ADXL34X_SPI) += adxl34x-spi.o 17 17 obj-$(CONFIG_INPUT_APANEL) += apanel.o 18 + obj-$(CONFIG_INPUT_ARIEL_PWRBUTTON) += ariel-pwrbutton.o 18 19 obj-$(CONFIG_INPUT_ARIZONA_HAPTICS) += arizona-haptics.o 19 20 obj-$(CONFIG_INPUT_ATI_REMOTE2) += ati_remote2.o 20 21 obj-$(CONFIG_INPUT_ATLAS_BTNS) += atlas_btns.o ··· 26 25 obj-$(CONFIG_INPUT_CMA3000_I2C) += cma3000_d0x_i2c.o 27 26 obj-$(CONFIG_INPUT_COBALT_BTNS) += cobalt_btns.o 28 27 obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON) += cpcap-pwrbutton.o 28 + obj-$(CONFIG_INPUT_DA7280_HAPTICS) += da7280.o 29 29 obj-$(CONFIG_INPUT_DA9052_ONKEY) += da9052_onkey.o 30 30 obj-$(CONFIG_INPUT_DA9055_ONKEY) += da9055_onkey.o 31 31 obj-$(CONFIG_INPUT_DA9063_ONKEY) += da9063_onkey.o
+1 -1
drivers/input/misc/ab8500-ponkey.c
··· 19 19 20 20 /** 21 21 * struct ab8500_ponkey - ab8500 ponkey information 22 - * @input_dev: pointer to input device 22 + * @idev: pointer to input device 23 23 * @ab8500: ab8500 parent 24 24 * @irq_dbf: irq number for falling transition 25 25 * @irq_dbr: irq number for rising transition
+169
drivers/input/misc/ariel-pwrbutton.c
··· 1 + // SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0-or-later 2 + /* 3 + * Dell Wyse 3020 a.k.a. "Ariel" Power Button Driver 4 + * 5 + * Copyright (C) 2020 Lubomir Rintel 6 + */ 7 + 8 + #include <linux/device.h> 9 + #include <linux/gfp.h> 10 + #include <linux/input.h> 11 + #include <linux/interrupt.h> 12 + #include <linux/mod_devicetable.h> 13 + #include <linux/module.h> 14 + #include <linux/spi/spi.h> 15 + 16 + #define RESP_COUNTER(response) (response.header & 0x3) 17 + #define RESP_SIZE(response) ((response.header >> 2) & 0x3) 18 + #define RESP_TYPE(response) ((response.header >> 4) & 0xf) 19 + 20 + struct ec_input_response { 21 + u8 reserved; 22 + u8 header; 23 + u8 data[3]; 24 + } __packed; 25 + 26 + struct ariel_pwrbutton { 27 + struct spi_device *client; 28 + struct input_dev *input; 29 + u8 msg_counter; 30 + }; 31 + 32 + static int ec_input_read(struct ariel_pwrbutton *priv, 33 + struct ec_input_response *response) 34 + { 35 + u8 read_request[] = { 0x00, 0x5a, 0xa5, 0x00, 0x00 }; 36 + struct spi_device *spi = priv->client; 37 + struct spi_transfer t = { 38 + .tx_buf = read_request, 39 + .rx_buf = response, 40 + .len = sizeof(read_request), 41 + }; 42 + 43 + compiletime_assert(sizeof(read_request) == sizeof(*response), 44 + "SPI xfer request/response size mismatch"); 45 + 46 + return spi_sync_transfer(spi, &t, 1); 47 + } 48 + 49 + static irqreturn_t ec_input_interrupt(int irq, void *dev_id) 50 + { 51 + struct ariel_pwrbutton *priv = dev_id; 52 + struct spi_device *spi = priv->client; 53 + struct ec_input_response response; 54 + int error; 55 + int i; 56 + 57 + error = ec_input_read(priv, &response); 58 + if (error < 0) { 59 + dev_err(&spi->dev, "EC read failed: %d\n", error); 60 + goto out; 61 + } 62 + 63 + if (priv->msg_counter == RESP_COUNTER(response)) { 64 + dev_warn(&spi->dev, "No new data to read?\n"); 65 + goto out; 66 + } 67 + 68 + priv->msg_counter = RESP_COUNTER(response); 69 + 70 + if (RESP_TYPE(response) != 0x3 && RESP_TYPE(response) != 0xc) { 71 + dev_dbg(&spi->dev, "Ignoring message that's not kbd data\n"); 72 + goto out; 73 + } 74 + 75 + for (i = 0; i < RESP_SIZE(response); i++) { 76 + switch (response.data[i]) { 77 + case 0x74: 78 + input_report_key(priv->input, KEY_POWER, 1); 79 + input_sync(priv->input); 80 + break; 81 + case 0xf4: 82 + input_report_key(priv->input, KEY_POWER, 0); 83 + input_sync(priv->input); 84 + break; 85 + default: 86 + dev_dbg(&spi->dev, "Unknown scan code: %02x\n", 87 + response.data[i]); 88 + } 89 + } 90 + 91 + out: 92 + return IRQ_HANDLED; 93 + } 94 + 95 + static int ariel_pwrbutton_probe(struct spi_device *spi) 96 + { 97 + struct ec_input_response response; 98 + struct ariel_pwrbutton *priv; 99 + int error; 100 + 101 + if (!spi->irq) { 102 + dev_err(&spi->dev, "Missing IRQ.\n"); 103 + return -EINVAL; 104 + } 105 + 106 + priv = devm_kzalloc(&spi->dev, sizeof(*priv), GFP_KERNEL); 107 + if (!priv) 108 + return -ENOMEM; 109 + 110 + priv->client = spi; 111 + spi_set_drvdata(spi, priv); 112 + 113 + priv->input = devm_input_allocate_device(&spi->dev); 114 + if (!priv->input) 115 + return -ENOMEM; 116 + priv->input->name = "Power Button"; 117 + priv->input->dev.parent = &spi->dev; 118 + input_set_capability(priv->input, EV_KEY, KEY_POWER); 119 + error = input_register_device(priv->input); 120 + if (error) { 121 + dev_err(&spi->dev, "error registering input device: %d\n", error); 122 + return error; 123 + } 124 + 125 + error = ec_input_read(priv, &response); 126 + if (error < 0) { 127 + dev_err(&spi->dev, "EC read failed: %d\n", error); 128 + return error; 129 + } 130 + priv->msg_counter = RESP_COUNTER(response); 131 + 132 + error = devm_request_threaded_irq(&spi->dev, spi->irq, NULL, 133 + ec_input_interrupt, 134 + IRQF_ONESHOT, 135 + "Ariel EC Input", priv); 136 + 137 + if (error) { 138 + dev_err(&spi->dev, "Failed to request IRQ %d: %d\n", 139 + spi->irq, error); 140 + return error; 141 + } 142 + 143 + return 0; 144 + } 145 + 146 + static const struct of_device_id ariel_pwrbutton_of_match[] = { 147 + { .compatible = "dell,wyse-ariel-ec-input" }, 148 + { } 149 + }; 150 + MODULE_DEVICE_TABLE(of, ariel_pwrbutton_of_match); 151 + 152 + static const struct spi_device_id ariel_pwrbutton_id_table[] = { 153 + { "wyse-ariel-ec-input", 0 }, 154 + {} 155 + }; 156 + MODULE_DEVICE_TABLE(spi, ariel_pwrbutton_id_table); 157 + 158 + static struct spi_driver ariel_pwrbutton_driver = { 159 + .driver = { 160 + .name = "dell-wyse-ariel-ec-input", 161 + .of_match_table = ariel_pwrbutton_of_match, 162 + }, 163 + .probe = ariel_pwrbutton_probe, 164 + }; 165 + module_spi_driver(ariel_pwrbutton_driver); 166 + 167 + MODULE_AUTHOR("Lubomir Rintel <lkundrak@v3.sk>"); 168 + MODULE_DESCRIPTION("Dell Wyse 3020 Power Button Input Driver"); 169 + MODULE_LICENSE("Dual BSD/GPL");
+1329
drivers/input/misc/da7280.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * DA7280 Haptic device driver 4 + * 5 + * Copyright (c) 2020 Dialog Semiconductor. 6 + * Author: Roy Im <Roy.Im.Opensource@diasemi.com> 7 + */ 8 + 9 + #include <linux/bitfield.h> 10 + #include <linux/bitops.h> 11 + #include <linux/err.h> 12 + #include <linux/i2c.h> 13 + #include <linux/input.h> 14 + #include <linux/interrupt.h> 15 + #include <linux/module.h> 16 + #include <linux/pwm.h> 17 + #include <linux/regmap.h> 18 + #include <linux/workqueue.h> 19 + #include <linux/uaccess.h> 20 + 21 + /* Registers */ 22 + #define DA7280_IRQ_EVENT1 0x03 23 + #define DA7280_IRQ_EVENT_WARNING_DIAG 0x04 24 + #define DA7280_IRQ_EVENT_SEQ_DIAG 0x05 25 + #define DA7280_IRQ_STATUS1 0x06 26 + #define DA7280_IRQ_MASK1 0x07 27 + #define DA7280_FRQ_LRA_PER_H 0x0A 28 + #define DA7280_FRQ_LRA_PER_L 0x0B 29 + #define DA7280_ACTUATOR1 0x0C 30 + #define DA7280_ACTUATOR2 0x0D 31 + #define DA7280_ACTUATOR3 0x0E 32 + #define DA7280_CALIB_V2I_H 0x0F 33 + #define DA7280_CALIB_V2I_L 0x10 34 + #define DA7280_TOP_CFG1 0x13 35 + #define DA7280_TOP_CFG2 0x14 36 + #define DA7280_TOP_CFG4 0x16 37 + #define DA7280_TOP_INT_CFG1 0x17 38 + #define DA7280_TOP_CTL1 0x22 39 + #define DA7280_TOP_CTL2 0x23 40 + #define DA7280_SEQ_CTL2 0x28 41 + #define DA7280_GPI_0_CTL 0x29 42 + #define DA7280_GPI_1_CTL 0x2A 43 + #define DA7280_GPI_2_CTL 0x2B 44 + #define DA7280_MEM_CTL1 0x2C 45 + #define DA7280_MEM_CTL2 0x2D 46 + #define DA7280_TOP_CFG5 0x6E 47 + #define DA7280_IRQ_MASK2 0x83 48 + #define DA7280_SNP_MEM_99 0xE7 49 + 50 + /* Register field */ 51 + 52 + /* DA7280_IRQ_EVENT1 (Address 0x03) */ 53 + #define DA7280_E_SEQ_CONTINUE_MASK BIT(0) 54 + #define DA7280_E_UVLO_MASK BIT(1) 55 + #define DA7280_E_SEQ_DONE_MASK BIT(2) 56 + #define DA7280_E_OVERTEMP_CRIT_MASK BIT(3) 57 + #define DA7280_E_SEQ_FAULT_MASK BIT(4) 58 + #define DA7280_E_WARNING_MASK BIT(5) 59 + #define DA7280_E_ACTUATOR_FAULT_MASK BIT(6) 60 + #define DA7280_E_OC_FAULT_MASK BIT(7) 61 + 62 + /* DA7280_IRQ_EVENT_WARNING_DIAG (Address 0x04) */ 63 + #define DA7280_E_OVERTEMP_WARN_MASK BIT(3) 64 + #define DA7280_E_MEM_TYPE_MASK BIT(4) 65 + #define DA7280_E_LIM_DRIVE_ACC_MASK BIT(6) 66 + #define DA7280_E_LIM_DRIVE_MASK BIT(7) 67 + 68 + /* DA7280_IRQ_EVENT_PAT_DIAG (Address 0x05) */ 69 + #define DA7280_E_PWM_FAULT_MASK BIT(5) 70 + #define DA7280_E_MEM_FAULT_MASK BIT(6) 71 + #define DA7280_E_SEQ_ID_FAULT_MASK BIT(7) 72 + 73 + /* DA7280_IRQ_STATUS1 (Address 0x06) */ 74 + #define DA7280_STA_SEQ_CONTINUE_MASK BIT(0) 75 + #define DA7280_STA_UVLO_VBAT_OK_MASK BIT(1) 76 + #define DA7280_STA_SEQ_DONE_MASK BIT(2) 77 + #define DA7280_STA_OVERTEMP_CRIT_MASK BIT(3) 78 + #define DA7280_STA_SEQ_FAULT_MASK BIT(4) 79 + #define DA7280_STA_WARNING_MASK BIT(5) 80 + #define DA7280_STA_ACTUATOR_MASK BIT(6) 81 + #define DA7280_STA_OC_MASK BIT(7) 82 + 83 + /* DA7280_IRQ_MASK1 (Address 0x07) */ 84 + #define DA7280_SEQ_CONTINUE_M_MASK BIT(0) 85 + #define DA7280_E_UVLO_M_MASK BIT(1) 86 + #define DA7280_SEQ_DONE_M_MASK BIT(2) 87 + #define DA7280_OVERTEMP_CRIT_M_MASK BIT(3) 88 + #define DA7280_SEQ_FAULT_M_MASK BIT(4) 89 + #define DA7280_WARNING_M_MASK BIT(5) 90 + #define DA7280_ACTUATOR_M_MASK BIT(6) 91 + #define DA7280_OC_M_MASK BIT(7) 92 + 93 + /* DA7280_ACTUATOR3 (Address 0x0e) */ 94 + #define DA7280_IMAX_MASK GENMASK(4, 0) 95 + 96 + /* DA7280_TOP_CFG1 (Address 0x13) */ 97 + #define DA7280_AMP_PID_EN_MASK BIT(0) 98 + #define DA7280_RAPID_STOP_EN_MASK BIT(1) 99 + #define DA7280_ACCELERATION_EN_MASK BIT(2) 100 + #define DA7280_FREQ_TRACK_EN_MASK BIT(3) 101 + #define DA7280_BEMF_SENSE_EN_MASK BIT(4) 102 + #define DA7280_ACTUATOR_TYPE_MASK BIT(5) 103 + 104 + /* DA7280_TOP_CFG2 (Address 0x14) */ 105 + #define DA7280_FULL_BRAKE_THR_MASK GENMASK(3, 0) 106 + #define DA7280_MEM_DATA_SIGNED_MASK BIT(4) 107 + 108 + /* DA7280_TOP_CFG4 (Address 0x16) */ 109 + #define DA7280_TST_CALIB_IMPEDANCE_DIS_MASK BIT(6) 110 + #define DA7280_V2I_FACTOR_FREEZE_MASK BIT(7) 111 + 112 + /* DA7280_TOP_INT_CFG1 (Address 0x17) */ 113 + #define DA7280_BEMF_FAULT_LIM_MASK GENMASK(1, 0) 114 + 115 + /* DA7280_TOP_CTL1 (Address 0x22) */ 116 + #define DA7280_OPERATION_MODE_MASK GENMASK(2, 0) 117 + #define DA7280_STANDBY_EN_MASK BIT(3) 118 + #define DA7280_SEQ_START_MASK BIT(4) 119 + 120 + /* DA7280_SEQ_CTL2 (Address 0x28) */ 121 + #define DA7280_PS_SEQ_ID_MASK GENMASK(3, 0) 122 + #define DA7280_PS_SEQ_LOOP_MASK GENMASK(7, 4) 123 + 124 + /* DA7280_GPIO_0_CTL (Address 0x29) */ 125 + #define DA7280_GPI0_POLARITY_MASK GENMASK(1, 0) 126 + #define DA7280_GPI0_MODE_MASK BIT(2) 127 + #define DA7280_GPI0_SEQUENCE_ID_MASK GENMASK(6, 3) 128 + 129 + /* DA7280_GPIO_1_CTL (Address 0x2a) */ 130 + #define DA7280_GPI1_POLARITY_MASK GENMASK(1, 0) 131 + #define DA7280_GPI1_MODE_MASK BIT(2) 132 + #define DA7280_GPI1_SEQUENCE_ID_MASK GENMASK(6, 3) 133 + 134 + /* DA7280_GPIO_2_CTL (Address 0x2b) */ 135 + #define DA7280_GPI2_POLARITY_MASK GENMASK(1, 0) 136 + #define DA7280_GPI2_MODE_MASK BIT(2) 137 + #define DA7280_GPI2_SEQUENCE_ID_MASK GENMASK(6, 3) 138 + 139 + /* DA7280_MEM_CTL2 (Address 0x2d) */ 140 + #define DA7280_WAV_MEM_LOCK_MASK BIT(7) 141 + 142 + /* DA7280_TOP_CFG5 (Address 0x6e) */ 143 + #define DA7280_V2I_FACTOR_OFFSET_EN_MASK BIT(0) 144 + 145 + /* DA7280_IRQ_MASK2 (Address 0x83) */ 146 + #define DA7280_ADC_SAT_M_MASK BIT(7) 147 + 148 + /* Controls */ 149 + 150 + #define DA7280_VOLTAGE_RATE_MAX 6000000 151 + #define DA7280_VOLTAGE_RATE_STEP 23400 152 + #define DA7280_NOMMAX_DFT 0x6B 153 + #define DA7280_ABSMAX_DFT 0x78 154 + 155 + #define DA7280_IMPD_MAX 1500000000 156 + #define DA7280_IMPD_DEFAULT 22000000 157 + 158 + #define DA7280_IMAX_DEFAULT 0x0E 159 + #define DA7280_IMAX_STEP 7200 160 + #define DA7280_IMAX_LIMIT 252000 161 + 162 + #define DA7280_RESONT_FREQH_DFT 0x39 163 + #define DA7280_RESONT_FREQL_DFT 0x32 164 + #define DA7280_MIN_RESONAT_FREQ_HZ 50 165 + #define DA7280_MAX_RESONAT_FREQ_HZ 300 166 + 167 + #define DA7280_SEQ_ID_MAX 15 168 + #define DA7280_SEQ_LOOP_MAX 15 169 + #define DA7280_GPI_SEQ_ID_DFT 0 170 + #define DA7280_GPI_SEQ_ID_MAX 2 171 + 172 + #define DA7280_SNP_MEM_SIZE 100 173 + #define DA7280_SNP_MEM_MAX DA7280_SNP_MEM_99 174 + 175 + #define DA7280_IRQ_NUM 3 176 + 177 + #define DA7280_SKIP_INIT 0x100 178 + 179 + #define DA7280_FF_EFFECT_COUNT_MAX 15 180 + 181 + /* Maximum gain is 0x7fff for PWM mode */ 182 + #define DA7280_MAX_MAGNITUDE_SHIFT 15 183 + 184 + enum da7280_haptic_dev_t { 185 + DA7280_LRA = 0, 186 + DA7280_ERM_BAR = 1, 187 + DA7280_ERM_COIN = 2, 188 + DA7280_DEV_MAX, 189 + }; 190 + 191 + enum da7280_op_mode { 192 + DA7280_INACTIVE = 0, 193 + DA7280_DRO_MODE = 1, 194 + DA7280_PWM_MODE = 2, 195 + DA7280_RTWM_MODE = 3, 196 + DA7280_ETWM_MODE = 4, 197 + DA7280_OPMODE_MAX, 198 + }; 199 + 200 + #define DA7280_FF_CONSTANT_DRO 1 201 + #define DA7280_FF_PERIODIC_PWM 2 202 + #define DA7280_FF_PERIODIC_RTWM 1 203 + #define DA7280_FF_PERIODIC_ETWM 2 204 + 205 + #define DA7280_FF_PERIODIC_MODE DA7280_RTWM_MODE 206 + #define DA7280_FF_CONSTANT_MODE DA7280_DRO_MODE 207 + 208 + enum da7280_custom_effect_param { 209 + DA7280_CUSTOM_SEQ_ID_IDX = 0, 210 + DA7280_CUSTOM_SEQ_LOOP_IDX = 1, 211 + DA7280_CUSTOM_DATA_LEN = 2, 212 + }; 213 + 214 + enum da7280_custom_gpi_effect_param { 215 + DA7280_CUSTOM_GPI_SEQ_ID_IDX = 0, 216 + DA7280_CUSTOM_GPI_NUM_IDX = 2, 217 + DA7280_CUSTOM_GP_DATA_LEN = 3, 218 + }; 219 + 220 + struct da7280_gpi_ctl { 221 + u8 seq_id; 222 + u8 mode; 223 + u8 polarity; 224 + }; 225 + 226 + struct da7280_haptic { 227 + struct regmap *regmap; 228 + struct input_dev *input_dev; 229 + struct device *dev; 230 + struct i2c_client *client; 231 + struct pwm_device *pwm_dev; 232 + 233 + bool legacy; 234 + struct work_struct work; 235 + int val; 236 + u16 gain; 237 + s16 level; 238 + 239 + u8 dev_type; 240 + u8 op_mode; 241 + u8 const_op_mode; 242 + u8 periodic_op_mode; 243 + u16 nommax; 244 + u16 absmax; 245 + u32 imax; 246 + u32 impd; 247 + u32 resonant_freq_h; 248 + u32 resonant_freq_l; 249 + bool bemf_sense_en; 250 + bool freq_track_en; 251 + bool acc_en; 252 + bool rapid_stop_en; 253 + bool amp_pid_en; 254 + u8 ps_seq_id; 255 + u8 ps_seq_loop; 256 + struct da7280_gpi_ctl gpi_ctl[3]; 257 + bool mem_update; 258 + u8 snp_mem[DA7280_SNP_MEM_SIZE]; 259 + bool active; 260 + bool suspended; 261 + }; 262 + 263 + static bool da7280_volatile_register(struct device *dev, unsigned int reg) 264 + { 265 + switch (reg) { 266 + case DA7280_IRQ_EVENT1: 267 + case DA7280_IRQ_EVENT_WARNING_DIAG: 268 + case DA7280_IRQ_EVENT_SEQ_DIAG: 269 + case DA7280_IRQ_STATUS1: 270 + case DA7280_TOP_CTL1: 271 + return true; 272 + default: 273 + return false; 274 + } 275 + } 276 + 277 + static const struct regmap_config da7280_haptic_regmap_config = { 278 + .reg_bits = 8, 279 + .val_bits = 8, 280 + .max_register = DA7280_SNP_MEM_MAX, 281 + .volatile_reg = da7280_volatile_register, 282 + }; 283 + 284 + static int da7280_haptic_mem_update(struct da7280_haptic *haptics) 285 + { 286 + unsigned int val; 287 + int error; 288 + 289 + /* The patterns should be updated when haptic is not working */ 290 + error = regmap_read(haptics->regmap, DA7280_IRQ_STATUS1, &val); 291 + if (error) 292 + return error; 293 + if (val & DA7280_STA_WARNING_MASK) { 294 + dev_warn(haptics->dev, 295 + "Warning! Please check HAPTIC status.\n"); 296 + return -EBUSY; 297 + } 298 + 299 + /* Patterns are not updated if the lock bit is enabled */ 300 + val = 0; 301 + error = regmap_read(haptics->regmap, DA7280_MEM_CTL2, &val); 302 + if (error) 303 + return error; 304 + if (~val & DA7280_WAV_MEM_LOCK_MASK) { 305 + dev_warn(haptics->dev, "Please unlock the bit first\n"); 306 + return -EACCES; 307 + } 308 + 309 + /* Set to Inactive mode to make sure safety */ 310 + error = regmap_update_bits(haptics->regmap, 311 + DA7280_TOP_CTL1, 312 + DA7280_OPERATION_MODE_MASK, 313 + 0); 314 + if (error) 315 + return error; 316 + 317 + error = regmap_read(haptics->regmap, DA7280_MEM_CTL1, &val); 318 + if (error) 319 + return error; 320 + 321 + return regmap_bulk_write(haptics->regmap, val, haptics->snp_mem, 322 + DA7280_SNP_MEM_MAX - val + 1); 323 + } 324 + 325 + static int da7280_haptic_set_pwm(struct da7280_haptic *haptics, bool enabled) 326 + { 327 + struct pwm_state state; 328 + u64 period_mag_multi; 329 + int error; 330 + 331 + if (!haptics->gain && enabled) { 332 + dev_err(haptics->dev, "Unable to enable pwm with 0 gain\n"); 333 + return -EINVAL; 334 + } 335 + 336 + pwm_get_state(haptics->pwm_dev, &state); 337 + state.enabled = enabled; 338 + if (enabled) { 339 + period_mag_multi = (u64)state.period * haptics->gain; 340 + period_mag_multi >>= DA7280_MAX_MAGNITUDE_SHIFT; 341 + 342 + /* 343 + * The interpretation of duty cycle depends on the acc_en, 344 + * it should be between 50% and 100% for acc_en = 0. 345 + * See datasheet 'PWM mode' section. 346 + */ 347 + if (!haptics->acc_en) { 348 + period_mag_multi += state.period; 349 + period_mag_multi /= 2; 350 + } 351 + 352 + state.duty_cycle = period_mag_multi; 353 + } 354 + 355 + error = pwm_apply_state(haptics->pwm_dev, &state); 356 + if (error) 357 + dev_err(haptics->dev, "Failed to apply pwm state: %d\n", error); 358 + 359 + return error; 360 + } 361 + 362 + static void da7280_haptic_activate(struct da7280_haptic *haptics) 363 + { 364 + int error; 365 + 366 + if (haptics->active) 367 + return; 368 + 369 + switch (haptics->op_mode) { 370 + case DA7280_DRO_MODE: 371 + /* the valid range check when acc_en is enabled */ 372 + if (haptics->acc_en && haptics->level > 0x7F) 373 + haptics->level = 0x7F; 374 + else if (haptics->level > 0xFF) 375 + haptics->level = 0xFF; 376 + 377 + /* Set level as a % of ACTUATOR_NOMMAX (nommax) */ 378 + error = regmap_write(haptics->regmap, DA7280_TOP_CTL2, 379 + haptics->level); 380 + if (error) { 381 + dev_err(haptics->dev, 382 + "Failed to set level to %d: %d\n", 383 + haptics->level, error); 384 + return; 385 + } 386 + break; 387 + 388 + case DA7280_PWM_MODE: 389 + if (da7280_haptic_set_pwm(haptics, true)) 390 + return; 391 + break; 392 + 393 + case DA7280_RTWM_MODE: 394 + /* 395 + * The pattern will be played by the PS_SEQ_ID and the 396 + * PS_SEQ_LOOP 397 + */ 398 + break; 399 + 400 + case DA7280_ETWM_MODE: 401 + /* 402 + * The pattern will be played by the GPI[N] state, 403 + * GPI(N)_SEQUENCE_ID and the PS_SEQ_LOOP. See the 404 + * datasheet for the details. 405 + */ 406 + break; 407 + 408 + default: 409 + dev_err(haptics->dev, "Invalid op mode %d\n", haptics->op_mode); 410 + return; 411 + } 412 + 413 + error = regmap_update_bits(haptics->regmap, 414 + DA7280_TOP_CTL1, 415 + DA7280_OPERATION_MODE_MASK, 416 + haptics->op_mode); 417 + if (error) { 418 + dev_err(haptics->dev, 419 + "Failed to set operation mode: %d", error); 420 + return; 421 + } 422 + 423 + if (haptics->op_mode == DA7280_PWM_MODE || 424 + haptics->op_mode == DA7280_RTWM_MODE) { 425 + error = regmap_update_bits(haptics->regmap, 426 + DA7280_TOP_CTL1, 427 + DA7280_SEQ_START_MASK, 428 + DA7280_SEQ_START_MASK); 429 + if (error) { 430 + dev_err(haptics->dev, 431 + "Failed to start sequence: %d\n", error); 432 + return; 433 + } 434 + } 435 + 436 + haptics->active = true; 437 + } 438 + 439 + static void da7280_haptic_deactivate(struct da7280_haptic *haptics) 440 + { 441 + int error; 442 + 443 + if (!haptics->active) 444 + return; 445 + 446 + /* Set to Inactive mode */ 447 + error = regmap_update_bits(haptics->regmap, 448 + DA7280_TOP_CTL1, 449 + DA7280_OPERATION_MODE_MASK, 0); 450 + if (error) { 451 + dev_err(haptics->dev, 452 + "Failed to clear operation mode: %d", error); 453 + return; 454 + } 455 + 456 + switch (haptics->op_mode) { 457 + case DA7280_DRO_MODE: 458 + error = regmap_write(haptics->regmap, 459 + DA7280_TOP_CTL2, 0); 460 + if (error) { 461 + dev_err(haptics->dev, 462 + "Failed to disable DRO mode: %d\n", error); 463 + return; 464 + } 465 + break; 466 + 467 + case DA7280_PWM_MODE: 468 + if (da7280_haptic_set_pwm(haptics, false)) 469 + return; 470 + break; 471 + 472 + case DA7280_RTWM_MODE: 473 + case DA7280_ETWM_MODE: 474 + error = regmap_update_bits(haptics->regmap, 475 + DA7280_TOP_CTL1, 476 + DA7280_SEQ_START_MASK, 0); 477 + if (error) { 478 + dev_err(haptics->dev, 479 + "Failed to disable RTWM/ETWM mode: %d\n", 480 + error); 481 + return; 482 + } 483 + break; 484 + 485 + default: 486 + dev_err(haptics->dev, "Invalid op mode %d\n", haptics->op_mode); 487 + return; 488 + } 489 + 490 + haptics->active = false; 491 + } 492 + 493 + static void da7280_haptic_work(struct work_struct *work) 494 + { 495 + struct da7280_haptic *haptics = 496 + container_of(work, struct da7280_haptic, work); 497 + int val = haptics->val; 498 + 499 + if (val) 500 + da7280_haptic_activate(haptics); 501 + else 502 + da7280_haptic_deactivate(haptics); 503 + } 504 + 505 + static int da7280_haptics_upload_effect(struct input_dev *dev, 506 + struct ff_effect *effect, 507 + struct ff_effect *old) 508 + { 509 + struct da7280_haptic *haptics = input_get_drvdata(dev); 510 + s16 data[DA7280_SNP_MEM_SIZE] = { 0 }; 511 + unsigned int val; 512 + int tmp, i, num; 513 + int error; 514 + 515 + /* The effect should be uploaded when haptic is not working */ 516 + if (haptics->active) 517 + return -EBUSY; 518 + 519 + switch (effect->type) { 520 + /* DRO/PWM modes support this type */ 521 + case FF_CONSTANT: 522 + haptics->op_mode = haptics->const_op_mode; 523 + if (haptics->op_mode == DA7280_DRO_MODE) { 524 + tmp = effect->u.constant.level * 254; 525 + haptics->level = tmp / 0x7FFF; 526 + break; 527 + } 528 + 529 + haptics->gain = effect->u.constant.level <= 0 ? 530 + 0 : effect->u.constant.level; 531 + break; 532 + 533 + /* RTWM/ETWM modes support this type */ 534 + case FF_PERIODIC: 535 + if (effect->u.periodic.waveform != FF_CUSTOM) { 536 + dev_err(haptics->dev, 537 + "Device can only accept FF_CUSTOM waveform\n"); 538 + return -EINVAL; 539 + } 540 + 541 + /* 542 + * Load the data and check the length. 543 + * the data will be patterns in this case: 4 < X <= 100, 544 + * and will be saved into the waveform memory inside DA728x. 545 + * If X = 2, the data will be PS_SEQ_ID and PS_SEQ_LOOP. 546 + * If X = 3, the 1st data will be GPIX_SEQUENCE_ID . 547 + */ 548 + if (effect->u.periodic.custom_len == DA7280_CUSTOM_DATA_LEN) 549 + goto set_seq_id_loop; 550 + 551 + if (effect->u.periodic.custom_len == DA7280_CUSTOM_GP_DATA_LEN) 552 + goto set_gpix_seq_id; 553 + 554 + if (effect->u.periodic.custom_len < DA7280_CUSTOM_DATA_LEN || 555 + effect->u.periodic.custom_len > DA7280_SNP_MEM_SIZE) { 556 + dev_err(haptics->dev, "Invalid waveform data size\n"); 557 + return -EINVAL; 558 + } 559 + 560 + if (copy_from_user(data, effect->u.periodic.custom_data, 561 + sizeof(s16) * 562 + effect->u.periodic.custom_len)) 563 + return -EFAULT; 564 + 565 + memset(haptics->snp_mem, 0, DA7280_SNP_MEM_SIZE); 566 + 567 + for (i = 0; i < effect->u.periodic.custom_len; i++) { 568 + if (data[i] < 0 || data[i] > 0xff) { 569 + dev_err(haptics->dev, 570 + "Invalid waveform data %d at offset %d\n", 571 + data[i], i); 572 + return -EINVAL; 573 + } 574 + haptics->snp_mem[i] = (u8)data[i]; 575 + } 576 + 577 + error = da7280_haptic_mem_update(haptics); 578 + if (error) { 579 + dev_err(haptics->dev, 580 + "Failed to upload waveform: %d\n", error); 581 + return error; 582 + } 583 + break; 584 + 585 + set_seq_id_loop: 586 + if (copy_from_user(data, effect->u.periodic.custom_data, 587 + sizeof(s16) * DA7280_CUSTOM_DATA_LEN)) 588 + return -EFAULT; 589 + 590 + if (data[DA7280_CUSTOM_SEQ_ID_IDX] < 0 || 591 + data[DA7280_CUSTOM_SEQ_ID_IDX] > DA7280_SEQ_ID_MAX || 592 + data[DA7280_CUSTOM_SEQ_LOOP_IDX] < 0 || 593 + data[DA7280_CUSTOM_SEQ_LOOP_IDX] > DA7280_SEQ_LOOP_MAX) { 594 + dev_err(haptics->dev, 595 + "Invalid custom id (%d) or loop (%d)\n", 596 + data[DA7280_CUSTOM_SEQ_ID_IDX], 597 + data[DA7280_CUSTOM_SEQ_LOOP_IDX]); 598 + return -EINVAL; 599 + } 600 + 601 + haptics->ps_seq_id = data[DA7280_CUSTOM_SEQ_ID_IDX] & 0x0f; 602 + haptics->ps_seq_loop = data[DA7280_CUSTOM_SEQ_LOOP_IDX] & 0x0f; 603 + haptics->op_mode = haptics->periodic_op_mode; 604 + 605 + val = FIELD_PREP(DA7280_PS_SEQ_ID_MASK, haptics->ps_seq_id) | 606 + FIELD_PREP(DA7280_PS_SEQ_LOOP_MASK, 607 + haptics->ps_seq_loop); 608 + error = regmap_write(haptics->regmap, DA7280_SEQ_CTL2, val); 609 + if (error) { 610 + dev_err(haptics->dev, 611 + "Failed to update PS sequence: %d\n", error); 612 + return error; 613 + } 614 + break; 615 + 616 + set_gpix_seq_id: 617 + if (copy_from_user(data, effect->u.periodic.custom_data, 618 + sizeof(s16) * DA7280_CUSTOM_GP_DATA_LEN)) 619 + return -EFAULT; 620 + 621 + if (data[DA7280_CUSTOM_GPI_SEQ_ID_IDX] < 0 || 622 + data[DA7280_CUSTOM_GPI_SEQ_ID_IDX] > DA7280_SEQ_ID_MAX || 623 + data[DA7280_CUSTOM_GPI_NUM_IDX] < 0 || 624 + data[DA7280_CUSTOM_GPI_NUM_IDX] > DA7280_GPI_SEQ_ID_MAX) { 625 + dev_err(haptics->dev, 626 + "Invalid custom GPI id (%d) or num (%d)\n", 627 + data[DA7280_CUSTOM_GPI_SEQ_ID_IDX], 628 + data[DA7280_CUSTOM_GPI_NUM_IDX]); 629 + return -EINVAL; 630 + } 631 + 632 + num = data[DA7280_CUSTOM_GPI_NUM_IDX] & 0x0f; 633 + haptics->gpi_ctl[num].seq_id = 634 + data[DA7280_CUSTOM_GPI_SEQ_ID_IDX] & 0x0f; 635 + haptics->op_mode = haptics->periodic_op_mode; 636 + 637 + val = FIELD_PREP(DA7280_GPI0_SEQUENCE_ID_MASK, 638 + haptics->gpi_ctl[num].seq_id); 639 + error = regmap_update_bits(haptics->regmap, 640 + DA7280_GPI_0_CTL + num, 641 + DA7280_GPI0_SEQUENCE_ID_MASK, 642 + val); 643 + if (error) { 644 + dev_err(haptics->dev, 645 + "Failed to update GPI sequence: %d\n", error); 646 + return error; 647 + } 648 + break; 649 + 650 + default: 651 + dev_err(haptics->dev, "Unsupported effect type: %d\n", 652 + effect->type); 653 + return -EINVAL; 654 + } 655 + 656 + return 0; 657 + } 658 + 659 + static int da7280_haptics_playback(struct input_dev *dev, 660 + int effect_id, int val) 661 + { 662 + struct da7280_haptic *haptics = input_get_drvdata(dev); 663 + 664 + if (!haptics->op_mode) { 665 + dev_warn(haptics->dev, "No effects have been uploaded\n"); 666 + return -EINVAL; 667 + } 668 + 669 + if (likely(!haptics->suspended)) { 670 + haptics->val = val; 671 + schedule_work(&haptics->work); 672 + } 673 + 674 + return 0; 675 + } 676 + 677 + static int da7280_haptic_start(struct da7280_haptic *haptics) 678 + { 679 + int error; 680 + 681 + error = regmap_update_bits(haptics->regmap, 682 + DA7280_TOP_CTL1, 683 + DA7280_STANDBY_EN_MASK, 684 + DA7280_STANDBY_EN_MASK); 685 + if (error) { 686 + dev_err(haptics->dev, "Unable to enable device: %d\n", error); 687 + return error; 688 + } 689 + 690 + return 0; 691 + } 692 + 693 + static void da7280_haptic_stop(struct da7280_haptic *haptics) 694 + { 695 + int error; 696 + 697 + cancel_work_sync(&haptics->work); 698 + 699 + 700 + da7280_haptic_deactivate(haptics); 701 + 702 + error = regmap_update_bits(haptics->regmap, DA7280_TOP_CTL1, 703 + DA7280_STANDBY_EN_MASK, 0); 704 + if (error) 705 + dev_err(haptics->dev, "Failed to disable device: %d\n", error); 706 + } 707 + 708 + static int da7280_haptic_open(struct input_dev *dev) 709 + { 710 + struct da7280_haptic *haptics = input_get_drvdata(dev); 711 + 712 + return da7280_haptic_start(haptics); 713 + } 714 + 715 + static void da7280_haptic_close(struct input_dev *dev) 716 + { 717 + struct da7280_haptic *haptics = input_get_drvdata(dev); 718 + 719 + da7280_haptic_stop(haptics); 720 + } 721 + 722 + static u8 da7280_haptic_of_mode_str(struct device *dev, 723 + const char *str) 724 + { 725 + if (!strcmp(str, "LRA")) { 726 + return DA7280_LRA; 727 + } else if (!strcmp(str, "ERM-bar")) { 728 + return DA7280_ERM_BAR; 729 + } else if (!strcmp(str, "ERM-coin")) { 730 + return DA7280_ERM_COIN; 731 + } else { 732 + dev_warn(dev, "Invalid string - set to LRA\n"); 733 + return DA7280_LRA; 734 + } 735 + } 736 + 737 + static u8 da7280_haptic_of_gpi_mode_str(struct device *dev, 738 + const char *str) 739 + { 740 + if (!strcmp(str, "Single-pattern")) { 741 + return 0; 742 + } else if (!strcmp(str, "Multi-pattern")) { 743 + return 1; 744 + } else { 745 + dev_warn(dev, "Invalid string - set to Single-pattern\n"); 746 + return 0; 747 + } 748 + } 749 + 750 + static u8 da7280_haptic_of_gpi_pol_str(struct device *dev, 751 + const char *str) 752 + { 753 + if (!strcmp(str, "Rising-edge")) { 754 + return 0; 755 + } else if (!strcmp(str, "Falling-edge")) { 756 + return 1; 757 + } else if (!strcmp(str, "Both-edge")) { 758 + return 2; 759 + } else { 760 + dev_warn(dev, "Invalid string - set to Rising-edge\n"); 761 + return 0; 762 + } 763 + } 764 + 765 + static u8 da7280_haptic_of_volt_rating_set(u32 val) 766 + { 767 + u32 voltage = val / DA7280_VOLTAGE_RATE_STEP + 1; 768 + 769 + return min_t(u32, voltage, 0xff); 770 + } 771 + 772 + static void da7280_parse_properties(struct device *dev, 773 + struct da7280_haptic *haptics) 774 + { 775 + unsigned int i, mem[DA7280_SNP_MEM_SIZE]; 776 + char gpi_str1[] = "dlg,gpi0-seq-id"; 777 + char gpi_str2[] = "dlg,gpi0-mode"; 778 + char gpi_str3[] = "dlg,gpi0-polarity"; 779 + const char *str; 780 + u32 val; 781 + int error; 782 + 783 + /* 784 + * If there is no property, then use the mode programmed into the chip. 785 + */ 786 + haptics->dev_type = DA7280_DEV_MAX; 787 + error = device_property_read_string(dev, "dlg,actuator-type", &str); 788 + if (!error) 789 + haptics->dev_type = da7280_haptic_of_mode_str(dev, str); 790 + 791 + haptics->const_op_mode = DA7280_DRO_MODE; 792 + error = device_property_read_u32(dev, "dlg,const-op-mode", &val); 793 + if (!error && val == DA7280_FF_PERIODIC_PWM) 794 + haptics->const_op_mode = DA7280_PWM_MODE; 795 + 796 + haptics->periodic_op_mode = DA7280_RTWM_MODE; 797 + error = device_property_read_u32(dev, "dlg,periodic-op-mode", &val); 798 + if (!error && val == DA7280_FF_PERIODIC_ETWM) 799 + haptics->periodic_op_mode = DA7280_ETWM_MODE; 800 + 801 + haptics->nommax = DA7280_SKIP_INIT; 802 + error = device_property_read_u32(dev, "dlg,nom-microvolt", &val); 803 + if (!error && val < DA7280_VOLTAGE_RATE_MAX) 804 + haptics->nommax = da7280_haptic_of_volt_rating_set(val); 805 + 806 + haptics->absmax = DA7280_SKIP_INIT; 807 + error = device_property_read_u32(dev, "dlg,abs-max-microvolt", &val); 808 + if (!error && val < DA7280_VOLTAGE_RATE_MAX) 809 + haptics->absmax = da7280_haptic_of_volt_rating_set(val); 810 + 811 + haptics->imax = DA7280_IMAX_DEFAULT; 812 + error = device_property_read_u32(dev, "dlg,imax-microamp", &val); 813 + if (!error && val < DA7280_IMAX_LIMIT) 814 + haptics->imax = (val - 28600) / DA7280_IMAX_STEP + 1; 815 + 816 + haptics->impd = DA7280_IMPD_DEFAULT; 817 + error = device_property_read_u32(dev, "dlg,impd-micro-ohms", &val); 818 + if (!error && val <= DA7280_IMPD_MAX) 819 + haptics->impd = val; 820 + 821 + haptics->resonant_freq_h = DA7280_SKIP_INIT; 822 + haptics->resonant_freq_l = DA7280_SKIP_INIT; 823 + error = device_property_read_u32(dev, "dlg,resonant-freq-hz", &val); 824 + if (!error) { 825 + if (val < DA7280_MAX_RESONAT_FREQ_HZ && 826 + val > DA7280_MIN_RESONAT_FREQ_HZ) { 827 + haptics->resonant_freq_h = 828 + ((1000000000 / (val * 1333)) >> 7) & 0xFF; 829 + haptics->resonant_freq_l = 830 + (1000000000 / (val * 1333)) & 0x7F; 831 + } else { 832 + haptics->resonant_freq_h = DA7280_RESONT_FREQH_DFT; 833 + haptics->resonant_freq_l = DA7280_RESONT_FREQL_DFT; 834 + } 835 + } 836 + 837 + /* If no property, set to zero as default is to do nothing. */ 838 + haptics->ps_seq_id = 0; 839 + error = device_property_read_u32(dev, "dlg,ps-seq-id", &val); 840 + if (!error && val <= DA7280_SEQ_ID_MAX) 841 + haptics->ps_seq_id = val; 842 + 843 + haptics->ps_seq_loop = 0; 844 + error = device_property_read_u32(dev, "dlg,ps-seq-loop", &val); 845 + if (!error && val <= DA7280_SEQ_LOOP_MAX) 846 + haptics->ps_seq_loop = val; 847 + 848 + /* GPI0~2 Control */ 849 + for (i = 0; i <= DA7280_GPI_SEQ_ID_MAX; i++) { 850 + gpi_str1[7] = '0' + i; 851 + haptics->gpi_ctl[i].seq_id = DA7280_GPI_SEQ_ID_DFT + i; 852 + error = device_property_read_u32 (dev, gpi_str1, &val); 853 + if (!error && val <= DA7280_SEQ_ID_MAX) 854 + haptics->gpi_ctl[i].seq_id = val; 855 + 856 + gpi_str2[7] = '0' + i; 857 + haptics->gpi_ctl[i].mode = 0; 858 + error = device_property_read_string(dev, gpi_str2, &str); 859 + if (!error) 860 + haptics->gpi_ctl[i].mode = 861 + da7280_haptic_of_gpi_mode_str(dev, str); 862 + 863 + gpi_str3[7] = '0' + i; 864 + haptics->gpi_ctl[i].polarity = 0; 865 + error = device_property_read_string(dev, gpi_str3, &str); 866 + haptics->gpi_ctl[i].polarity = 867 + da7280_haptic_of_gpi_pol_str(dev, str); 868 + } 869 + 870 + haptics->bemf_sense_en = 871 + device_property_read_bool(dev, "dlg,bemf-sens-enable"); 872 + haptics->freq_track_en = 873 + device_property_read_bool(dev, "dlg,freq-track-enable"); 874 + haptics->acc_en = 875 + device_property_read_bool(dev, "dlg,acc-enable"); 876 + haptics->rapid_stop_en = 877 + device_property_read_bool(dev, "dlg,rapid-stop-enable"); 878 + haptics->amp_pid_en = 879 + device_property_read_bool(dev, "dlg,amp-pid-enable"); 880 + 881 + haptics->mem_update = false; 882 + error = device_property_read_u32_array(dev, "dlg,mem-array", 883 + &mem[0], DA7280_SNP_MEM_SIZE); 884 + if (!error) { 885 + haptics->mem_update = true; 886 + memset(haptics->snp_mem, 0, DA7280_SNP_MEM_SIZE); 887 + for (i = 0; i < DA7280_SNP_MEM_SIZE; i++) { 888 + if (mem[i] <= 0xff) { 889 + haptics->snp_mem[i] = (u8)mem[i]; 890 + } else { 891 + dev_err(haptics->dev, 892 + "Invalid data in mem-array at %d: %x\n", 893 + i, mem[i]); 894 + haptics->mem_update = false; 895 + break; 896 + } 897 + } 898 + } 899 + } 900 + 901 + static irqreturn_t da7280_irq_handler(int irq, void *data) 902 + { 903 + struct da7280_haptic *haptics = data; 904 + struct device *dev = haptics->dev; 905 + u8 events[DA7280_IRQ_NUM]; 906 + int error; 907 + 908 + /* Check what events have happened */ 909 + error = regmap_bulk_read(haptics->regmap, DA7280_IRQ_EVENT1, 910 + events, sizeof(events)); 911 + if (error) { 912 + dev_err(dev, "failed to read interrupt data: %d\n", error); 913 + goto out; 914 + } 915 + 916 + /* Clear events */ 917 + error = regmap_write(haptics->regmap, DA7280_IRQ_EVENT1, events[0]); 918 + if (error) { 919 + dev_err(dev, "failed to clear interrupts: %d\n", error); 920 + goto out; 921 + } 922 + 923 + if (events[0] & DA7280_E_SEQ_FAULT_MASK) { 924 + /* 925 + * Stop first if haptic is active, otherwise, the fault may 926 + * happen continually even though the bit is cleared. 927 + */ 928 + error = regmap_update_bits(haptics->regmap, DA7280_TOP_CTL1, 929 + DA7280_OPERATION_MODE_MASK, 0); 930 + if (error) 931 + dev_err(dev, "failed to clear op mode on fault: %d\n", 932 + error); 933 + } 934 + 935 + if (events[0] & DA7280_E_SEQ_DONE_MASK) 936 + haptics->active = false; 937 + 938 + if (events[0] & DA7280_E_WARNING_MASK) { 939 + if (events[1] & DA7280_E_LIM_DRIVE_MASK || 940 + events[1] & DA7280_E_LIM_DRIVE_ACC_MASK) 941 + dev_warn(dev, "Please reduce the driver level\n"); 942 + if (events[1] & DA7280_E_MEM_TYPE_MASK) 943 + dev_warn(dev, "Please check the mem data format\n"); 944 + if (events[1] & DA7280_E_OVERTEMP_WARN_MASK) 945 + dev_warn(dev, "Over-temperature warning\n"); 946 + } 947 + 948 + if (events[0] & DA7280_E_SEQ_FAULT_MASK) { 949 + if (events[2] & DA7280_E_SEQ_ID_FAULT_MASK) 950 + dev_info(dev, "Please reload PS_SEQ_ID & mem data\n"); 951 + if (events[2] & DA7280_E_MEM_FAULT_MASK) 952 + dev_info(dev, "Please reload the mem data\n"); 953 + if (events[2] & DA7280_E_PWM_FAULT_MASK) 954 + dev_info(dev, "Please restart PWM interface\n"); 955 + } 956 + 957 + out: 958 + return IRQ_HANDLED; 959 + } 960 + 961 + static int da7280_init(struct da7280_haptic *haptics) 962 + { 963 + unsigned int val = 0; 964 + u32 v2i_factor; 965 + int error, i; 966 + u8 mask = 0; 967 + 968 + /* 969 + * If device type is DA7280_DEV_MAX then simply use currently 970 + * programmed mode. 971 + */ 972 + if (haptics->dev_type == DA7280_DEV_MAX) { 973 + error = regmap_read(haptics->regmap, DA7280_TOP_CFG1, &val); 974 + if (error) 975 + goto out_err; 976 + 977 + haptics->dev_type = val & DA7280_ACTUATOR_TYPE_MASK ? 978 + DA7280_ERM_COIN : DA7280_LRA; 979 + } 980 + 981 + /* Apply user settings */ 982 + if (haptics->dev_type == DA7280_LRA && 983 + haptics->resonant_freq_l != DA7280_SKIP_INIT) { 984 + error = regmap_write(haptics->regmap, DA7280_FRQ_LRA_PER_H, 985 + haptics->resonant_freq_h); 986 + if (error) 987 + goto out_err; 988 + error = regmap_write(haptics->regmap, DA7280_FRQ_LRA_PER_L, 989 + haptics->resonant_freq_l); 990 + if (error) 991 + goto out_err; 992 + } else if (haptics->dev_type == DA7280_ERM_COIN) { 993 + error = regmap_update_bits(haptics->regmap, DA7280_TOP_INT_CFG1, 994 + DA7280_BEMF_FAULT_LIM_MASK, 0); 995 + if (error) 996 + goto out_err; 997 + 998 + mask = DA7280_TST_CALIB_IMPEDANCE_DIS_MASK | 999 + DA7280_V2I_FACTOR_FREEZE_MASK; 1000 + val = DA7280_TST_CALIB_IMPEDANCE_DIS_MASK | 1001 + DA7280_V2I_FACTOR_FREEZE_MASK; 1002 + error = regmap_update_bits(haptics->regmap, DA7280_TOP_CFG4, 1003 + mask, val); 1004 + if (error) 1005 + goto out_err; 1006 + 1007 + haptics->acc_en = false; 1008 + haptics->rapid_stop_en = false; 1009 + haptics->amp_pid_en = false; 1010 + } 1011 + 1012 + mask = DA7280_ACTUATOR_TYPE_MASK | 1013 + DA7280_BEMF_SENSE_EN_MASK | 1014 + DA7280_FREQ_TRACK_EN_MASK | 1015 + DA7280_ACCELERATION_EN_MASK | 1016 + DA7280_RAPID_STOP_EN_MASK | 1017 + DA7280_AMP_PID_EN_MASK; 1018 + val = FIELD_PREP(DA7280_ACTUATOR_TYPE_MASK, 1019 + (haptics->dev_type ? 1 : 0)) | 1020 + FIELD_PREP(DA7280_BEMF_SENSE_EN_MASK, 1021 + (haptics->bemf_sense_en ? 1 : 0)) | 1022 + FIELD_PREP(DA7280_FREQ_TRACK_EN_MASK, 1023 + (haptics->freq_track_en ? 1 : 0)) | 1024 + FIELD_PREP(DA7280_ACCELERATION_EN_MASK, 1025 + (haptics->acc_en ? 1 : 0)) | 1026 + FIELD_PREP(DA7280_RAPID_STOP_EN_MASK, 1027 + (haptics->rapid_stop_en ? 1 : 0)) | 1028 + FIELD_PREP(DA7280_AMP_PID_EN_MASK, 1029 + (haptics->amp_pid_en ? 1 : 0)); 1030 + 1031 + error = regmap_update_bits(haptics->regmap, DA7280_TOP_CFG1, mask, val); 1032 + if (error) 1033 + goto out_err; 1034 + 1035 + error = regmap_update_bits(haptics->regmap, DA7280_TOP_CFG5, 1036 + DA7280_V2I_FACTOR_OFFSET_EN_MASK, 1037 + haptics->acc_en ? 1038 + DA7280_V2I_FACTOR_OFFSET_EN_MASK : 0); 1039 + if (error) 1040 + goto out_err; 1041 + 1042 + error = regmap_update_bits(haptics->regmap, 1043 + DA7280_TOP_CFG2, 1044 + DA7280_MEM_DATA_SIGNED_MASK, 1045 + haptics->acc_en ? 1046 + 0 : DA7280_MEM_DATA_SIGNED_MASK); 1047 + if (error) 1048 + goto out_err; 1049 + 1050 + if (haptics->nommax != DA7280_SKIP_INIT) { 1051 + error = regmap_write(haptics->regmap, DA7280_ACTUATOR1, 1052 + haptics->nommax); 1053 + if (error) 1054 + goto out_err; 1055 + } 1056 + 1057 + if (haptics->absmax != DA7280_SKIP_INIT) { 1058 + error = regmap_write(haptics->regmap, DA7280_ACTUATOR2, 1059 + haptics->absmax); 1060 + if (error) 1061 + goto out_err; 1062 + } 1063 + 1064 + error = regmap_update_bits(haptics->regmap, DA7280_ACTUATOR3, 1065 + DA7280_IMAX_MASK, haptics->imax); 1066 + if (error) 1067 + goto out_err; 1068 + 1069 + v2i_factor = haptics->impd * (haptics->imax + 4) / 1610400; 1070 + error = regmap_write(haptics->regmap, DA7280_CALIB_V2I_L, 1071 + v2i_factor & 0xff); 1072 + if (error) 1073 + goto out_err; 1074 + error = regmap_write(haptics->regmap, DA7280_CALIB_V2I_H, 1075 + v2i_factor >> 8); 1076 + if (error) 1077 + goto out_err; 1078 + 1079 + error = regmap_update_bits(haptics->regmap, 1080 + DA7280_TOP_CTL1, 1081 + DA7280_STANDBY_EN_MASK, 1082 + DA7280_STANDBY_EN_MASK); 1083 + if (error) 1084 + goto out_err; 1085 + 1086 + if (haptics->mem_update) { 1087 + error = da7280_haptic_mem_update(haptics); 1088 + if (error) 1089 + goto out_err; 1090 + } 1091 + 1092 + /* Set PS_SEQ_ID and PS_SEQ_LOOP */ 1093 + val = FIELD_PREP(DA7280_PS_SEQ_ID_MASK, haptics->ps_seq_id) | 1094 + FIELD_PREP(DA7280_PS_SEQ_LOOP_MASK, haptics->ps_seq_loop); 1095 + error = regmap_write(haptics->regmap, DA7280_SEQ_CTL2, val); 1096 + if (error) 1097 + goto out_err; 1098 + 1099 + /* GPI(N) CTL */ 1100 + for (i = 0; i < 3; i++) { 1101 + val = FIELD_PREP(DA7280_GPI0_SEQUENCE_ID_MASK, 1102 + haptics->gpi_ctl[i].seq_id) | 1103 + FIELD_PREP(DA7280_GPI0_MODE_MASK, 1104 + haptics->gpi_ctl[i].mode) | 1105 + FIELD_PREP(DA7280_GPI0_POLARITY_MASK, 1106 + haptics->gpi_ctl[i].polarity); 1107 + error = regmap_write(haptics->regmap, 1108 + DA7280_GPI_0_CTL + i, val); 1109 + if (error) 1110 + goto out_err; 1111 + } 1112 + 1113 + /* Mask ADC_SAT_M bit as default */ 1114 + error = regmap_update_bits(haptics->regmap, 1115 + DA7280_IRQ_MASK2, 1116 + DA7280_ADC_SAT_M_MASK, 1117 + DA7280_ADC_SAT_M_MASK); 1118 + if (error) 1119 + goto out_err; 1120 + 1121 + /* Clear Interrupts */ 1122 + error = regmap_write(haptics->regmap, DA7280_IRQ_EVENT1, 0xff); 1123 + if (error) 1124 + goto out_err; 1125 + 1126 + error = regmap_update_bits(haptics->regmap, 1127 + DA7280_IRQ_MASK1, 1128 + DA7280_SEQ_FAULT_M_MASK | 1129 + DA7280_SEQ_DONE_M_MASK, 1130 + 0); 1131 + if (error) 1132 + goto out_err; 1133 + 1134 + haptics->active = false; 1135 + return 0; 1136 + 1137 + out_err: 1138 + dev_err(haptics->dev, "chip initialization error: %d\n", error); 1139 + return error; 1140 + } 1141 + 1142 + static int da7280_probe(struct i2c_client *client, 1143 + const struct i2c_device_id *id) 1144 + { 1145 + struct device *dev = &client->dev; 1146 + struct da7280_haptic *haptics; 1147 + struct input_dev *input_dev; 1148 + struct pwm_state state; 1149 + struct ff_device *ff; 1150 + int error; 1151 + 1152 + if (!client->irq) { 1153 + dev_err(dev, "No IRQ configured\n"); 1154 + return -EINVAL; 1155 + } 1156 + 1157 + haptics = devm_kzalloc(dev, sizeof(*haptics), GFP_KERNEL); 1158 + if (!haptics) 1159 + return -ENOMEM; 1160 + 1161 + haptics->dev = dev; 1162 + 1163 + da7280_parse_properties(dev, haptics); 1164 + 1165 + if (haptics->const_op_mode == DA7280_PWM_MODE) { 1166 + haptics->pwm_dev = devm_pwm_get(dev, NULL); 1167 + error = PTR_ERR_OR_ZERO(haptics->pwm_dev); 1168 + if (error) { 1169 + if (error != -EPROBE_DEFER) 1170 + dev_err(dev, "Unable to request PWM: %d\n", 1171 + error); 1172 + return error; 1173 + } 1174 + 1175 + /* Sync up PWM state and ensure it is off. */ 1176 + pwm_init_state(haptics->pwm_dev, &state); 1177 + state.enabled = false; 1178 + error = pwm_apply_state(haptics->pwm_dev, &state); 1179 + if (error) { 1180 + dev_err(dev, "Failed to apply PWM state: %d\n", error); 1181 + return error; 1182 + } 1183 + 1184 + /* 1185 + * Check PWM period, PWM freq = 1000000 / state.period. 1186 + * The valid PWM freq range: 10k ~ 250kHz. 1187 + */ 1188 + if (state.period > 100000 || state.period < 4000) { 1189 + dev_err(dev, "Unsupported PWM period: %lld\n", 1190 + state.period); 1191 + return -EINVAL; 1192 + } 1193 + } 1194 + 1195 + INIT_WORK(&haptics->work, da7280_haptic_work); 1196 + 1197 + haptics->client = client; 1198 + i2c_set_clientdata(client, haptics); 1199 + 1200 + haptics->regmap = devm_regmap_init_i2c(client, 1201 + &da7280_haptic_regmap_config); 1202 + error = PTR_ERR_OR_ZERO(haptics->regmap); 1203 + if (error) { 1204 + dev_err(dev, "Failed to allocate register map: %d\n", error); 1205 + return error; 1206 + } 1207 + 1208 + error = da7280_init(haptics); 1209 + if (error) { 1210 + dev_err(dev, "Failed to initialize device: %d\n", error); 1211 + return error; 1212 + } 1213 + 1214 + /* Initialize input device for haptic device */ 1215 + input_dev = devm_input_allocate_device(dev); 1216 + if (!input_dev) { 1217 + dev_err(dev, "Failed to allocate input device\n"); 1218 + return -ENOMEM; 1219 + } 1220 + 1221 + input_dev->name = "da7280-haptic"; 1222 + input_dev->dev.parent = client->dev.parent; 1223 + input_dev->open = da7280_haptic_open; 1224 + input_dev->close = da7280_haptic_close; 1225 + input_set_drvdata(input_dev, haptics); 1226 + haptics->input_dev = input_dev; 1227 + 1228 + input_set_capability(haptics->input_dev, EV_FF, FF_PERIODIC); 1229 + input_set_capability(haptics->input_dev, EV_FF, FF_CUSTOM); 1230 + input_set_capability(haptics->input_dev, EV_FF, FF_CONSTANT); 1231 + input_set_capability(haptics->input_dev, EV_FF, FF_GAIN); 1232 + 1233 + error = input_ff_create(haptics->input_dev, 1234 + DA7280_FF_EFFECT_COUNT_MAX); 1235 + if (error) { 1236 + dev_err(dev, "Failed to create FF input device: %d\n", error); 1237 + return error; 1238 + } 1239 + 1240 + ff = input_dev->ff; 1241 + ff->upload = da7280_haptics_upload_effect; 1242 + ff->playback = da7280_haptics_playback; 1243 + 1244 + error = input_register_device(input_dev); 1245 + if (error) { 1246 + dev_err(dev, "Failed to register input device: %d\n", error); 1247 + return error; 1248 + } 1249 + 1250 + error = devm_request_threaded_irq(dev, client->irq, 1251 + NULL, da7280_irq_handler, 1252 + IRQF_ONESHOT, 1253 + "da7280-haptics", haptics); 1254 + if (error) { 1255 + dev_err(dev, "Failed to request IRQ %d: %d\n", 1256 + client->irq, error); 1257 + return error; 1258 + } 1259 + 1260 + return 0; 1261 + } 1262 + 1263 + static int __maybe_unused da7280_suspend(struct device *dev) 1264 + { 1265 + struct da7280_haptic *haptics = dev_get_drvdata(dev); 1266 + 1267 + mutex_lock(&haptics->input_dev->mutex); 1268 + 1269 + /* 1270 + * Make sure no new requests will be submitted while device is 1271 + * suspended. 1272 + */ 1273 + spin_lock_irq(&haptics->input_dev->event_lock); 1274 + haptics->suspended = true; 1275 + spin_unlock_irq(&haptics->input_dev->event_lock); 1276 + 1277 + da7280_haptic_stop(haptics); 1278 + 1279 + mutex_unlock(&haptics->input_dev->mutex); 1280 + 1281 + return 0; 1282 + } 1283 + 1284 + static int __maybe_unused da7280_resume(struct device *dev) 1285 + { 1286 + struct da7280_haptic *haptics = dev_get_drvdata(dev); 1287 + int retval; 1288 + 1289 + mutex_lock(&haptics->input_dev->mutex); 1290 + 1291 + retval = da7280_haptic_start(haptics); 1292 + if (!retval) { 1293 + spin_lock_irq(&haptics->input_dev->event_lock); 1294 + haptics->suspended = false; 1295 + spin_unlock_irq(&haptics->input_dev->event_lock); 1296 + } 1297 + 1298 + mutex_unlock(&haptics->input_dev->mutex); 1299 + return retval; 1300 + } 1301 + 1302 + static const struct of_device_id da7280_of_match[] = { 1303 + { .compatible = "dlg,da7280", }, 1304 + { } 1305 + }; 1306 + MODULE_DEVICE_TABLE(of, da7280_of_match); 1307 + 1308 + static const struct i2c_device_id da7280_i2c_id[] = { 1309 + { "da7280", }, 1310 + { } 1311 + }; 1312 + MODULE_DEVICE_TABLE(i2c, da7280_i2c_id); 1313 + 1314 + static SIMPLE_DEV_PM_OPS(da7280_pm_ops, da7280_suspend, da7280_resume); 1315 + 1316 + static struct i2c_driver da7280_driver = { 1317 + .driver = { 1318 + .name = "da7280", 1319 + .of_match_table = of_match_ptr(da7280_of_match), 1320 + .pm = &da7280_pm_ops, 1321 + }, 1322 + .probe = da7280_probe, 1323 + .id_table = da7280_i2c_id, 1324 + }; 1325 + module_i2c_driver(da7280_driver); 1326 + 1327 + MODULE_DESCRIPTION("DA7280 haptics driver"); 1328 + MODULE_AUTHOR("Roy Im <Roy.Im.Opensource@diasemi.com>"); 1329 + MODULE_LICENSE("GPL");
+15 -15
drivers/input/misc/drv260x.c
··· 167 167 168 168 /** 169 169 * struct drv260x_data - 170 - * @input_dev - Pointer to the input device 171 - * @client - Pointer to the I2C client 172 - * @regmap - Register map of the device 173 - * @work - Work item used to off load the enable/disable of the vibration 174 - * @enable_gpio - Pointer to the gpio used for enable/disabling 175 - * @regulator - Pointer to the regulator for the IC 176 - * @magnitude - Magnitude of the vibration event 177 - * @mode - The operating mode of the IC (LRA_NO_CAL, ERM or LRA) 178 - * @library - The vibration library to be used 179 - * @rated_voltage - The rated_voltage of the actuator 180 - * @overdriver_voltage - The over drive voltage of the actuator 170 + * @input_dev: Pointer to the input device 171 + * @client: Pointer to the I2C client 172 + * @regmap: Register map of the device 173 + * @work: Work item used to off load the enable/disable of the vibration 174 + * @enable_gpio: Pointer to the gpio used for enable/disabling 175 + * @regulator: Pointer to the regulator for the IC 176 + * @magnitude: Magnitude of the vibration event 177 + * @mode: The operating mode of the IC (LRA_NO_CAL, ERM or LRA) 178 + * @library: The vibration library to be used 179 + * @rated_voltage: The rated_voltage of the actuator 180 + * @overdrive_voltage: The over drive voltage of the actuator 181 181 **/ 182 182 struct drv260x_data { 183 183 struct input_dev *input_dev; ··· 234 234 #define DRV260X_DEF_RATED_VOLT 0x90 235 235 #define DRV260X_DEF_OD_CLAMP_VOLT 0x90 236 236 237 - /** 237 + /* 238 238 * Rated and Overdriver Voltages: 239 239 * Calculated using the formula r = v * 255 / 5.6 240 240 * where r is what will be written to the register 241 241 * and v is the rated or overdriver voltage of the actuator 242 - **/ 242 + */ 243 243 static int drv260x_calculate_voltage(unsigned int voltage) 244 244 { 245 245 return (voltage * 255 / 5600); ··· 580 580 581 581 mutex_lock(&haptics->input_dev->mutex); 582 582 583 - if (haptics->input_dev->users) { 583 + if (input_device_enabled(haptics->input_dev)) { 584 584 ret = regmap_update_bits(haptics->regmap, 585 585 DRV260X_MODE, 586 586 DRV260X_STANDBY_MASK, ··· 612 612 613 613 mutex_lock(&haptics->input_dev->mutex); 614 614 615 - if (haptics->input_dev->users) { 615 + if (input_device_enabled(haptics->input_dev)) { 616 616 ret = regulator_enable(haptics->regulator); 617 617 if (ret) { 618 618 dev_err(dev, "Failed to enable regulator\n");
+7 -7
drivers/input/misc/drv2665.c
··· 44 44 45 45 /** 46 46 * struct drv2665_data - 47 - * @input_dev - Pointer to the input device 48 - * @client - Pointer to the I2C client 49 - * @regmap - Register map of the device 50 - * @work - Work item used to off load the enable/disable of the vibration 51 - * @regulator - Pointer to the regulator for the IC 47 + * @input_dev: Pointer to the input device 48 + * @client: Pointer to the I2C client 49 + * @regmap: Register map of the device 50 + * @work: Work item used to off load the enable/disable of the vibration 51 + * @regulator: Pointer to the regulator for the IC 52 52 */ 53 53 struct drv2665_data { 54 54 struct input_dev *input_dev; ··· 230 230 231 231 mutex_lock(&haptics->input_dev->mutex); 232 232 233 - if (haptics->input_dev->users) { 233 + if (input_device_enabled(haptics->input_dev)) { 234 234 ret = regmap_update_bits(haptics->regmap, DRV2665_CTRL_2, 235 235 DRV2665_STANDBY, DRV2665_STANDBY); 236 236 if (ret) { ··· 259 259 260 260 mutex_lock(&haptics->input_dev->mutex); 261 261 262 - if (haptics->input_dev->users) { 262 + if (input_device_enabled(haptics->input_dev)) { 263 263 ret = regulator_enable(haptics->regulator); 264 264 if (ret) { 265 265 dev_err(dev, "Failed to enable regulator\n");
+10 -8
drivers/input/misc/drv2667.c
··· 90 90 91 91 /** 92 92 * struct drv2667_data - 93 - * @input_dev - Pointer to the input device 94 - * @client - Pointer to the I2C client 95 - * @regmap - Register map of the device 96 - * @work - Work item used to off load the enable/disable of the vibration 97 - * @regulator - Pointer to the regulator for the IC 98 - * @magnitude - Magnitude of the vibration event 93 + * @input_dev: Pointer to the input device 94 + * @client: Pointer to the I2C client 95 + * @regmap: Register map of the device 96 + * @work: Work item used to off load the enable/disable of the vibration 97 + * @regulator: Pointer to the regulator for the IC 98 + * @page: Page number 99 + * @magnitude: Magnitude of the vibration event 100 + * @frequency: Frequency of the vibration event 99 101 **/ 100 102 struct drv2667_data { 101 103 struct input_dev *input_dev; ··· 407 405 408 406 mutex_lock(&haptics->input_dev->mutex); 409 407 410 - if (haptics->input_dev->users) { 408 + if (input_device_enabled(haptics->input_dev)) { 411 409 ret = regmap_update_bits(haptics->regmap, DRV2667_CTRL_2, 412 410 DRV2667_STANDBY, DRV2667_STANDBY); 413 411 if (ret) { ··· 436 434 437 435 mutex_lock(&haptics->input_dev->mutex); 438 436 439 - if (haptics->input_dev->users) { 437 + if (input_device_enabled(haptics->input_dev)) { 440 438 ret = regulator_enable(haptics->regulator); 441 439 if (ret) { 442 440 dev_err(dev, "Failed to enable regulator\n");
+1 -1
drivers/input/misc/ixp4xx-beeper.c
··· 97 97 98 98 input_set_drvdata(input_dev, (void *) dev->id); 99 99 100 - input_dev->name = "ixp4xx beeper", 100 + input_dev->name = "ixp4xx beeper"; 101 101 input_dev->phys = "ixp4xx/gpio"; 102 102 input_dev->id.bustype = BUS_HOST; 103 103 input_dev->id.vendor = 0x001f;
+2 -2
drivers/input/misc/kxtj9.c
··· 503 503 504 504 mutex_lock(&input_dev->mutex); 505 505 506 - if (input_dev->users) 506 + if (input_device_enabled(input_dev)) 507 507 kxtj9_disable(tj9); 508 508 509 509 mutex_unlock(&input_dev->mutex); ··· 518 518 519 519 mutex_lock(&input_dev->mutex); 520 520 521 - if (input_dev->users) 521 + if (input_device_enabled(input_dev)) 522 522 kxtj9_enable(tj9); 523 523 524 524 mutex_unlock(&input_dev->mutex);
+1 -1
drivers/input/misc/mc13783-pwrbutton.c
··· 1 - /** 1 + /* 2 2 * Copyright (C) 2011 Philippe Rétornaz 3 3 * 4 4 * Based on twl4030-pwrbutton driver by:
+1
drivers/input/misc/pcspkr.c
··· 33 33 case SND_BELL: 34 34 if (value) 35 35 value = 1000; 36 + break; 36 37 case SND_TONE: 37 38 break; 38 39 default:
+61 -14
drivers/input/misc/sc27xx-vibra.c
··· 3 3 * Copyright (C) 2018 Spreadtrum Communications Inc. 4 4 */ 5 5 6 - #include <linux/module.h> 7 - #include <linux/of_address.h> 8 - #include <linux/platform_device.h> 9 - #include <linux/regmap.h> 6 + #include <linux/device.h> 10 7 #include <linux/input.h> 8 + #include <linux/mod_devicetable.h> 9 + #include <linux/module.h> 10 + #include <linux/platform_device.h> 11 + #include <linux/property.h> 12 + #include <linux/regmap.h> 11 13 #include <linux/workqueue.h> 12 14 13 - #define CUR_DRV_CAL_SEL GENMASK(13, 12) 14 - #define SLP_LDOVIBR_PD_EN BIT(9) 15 - #define LDO_VIBR_PD BIT(8) 15 + #define CUR_DRV_CAL_SEL GENMASK(13, 12) 16 + #define SLP_LDOVIBR_PD_EN BIT(9) 17 + #define LDO_VIBR_PD BIT(8) 18 + #define SC2730_CUR_DRV_CAL_SEL 0 19 + #define SC2730_SLP_LDOVIBR_PD_EN BIT(14) 20 + #define SC2730_LDO_VIBR_PD BIT(13) 21 + 22 + struct sc27xx_vibra_data { 23 + u32 cur_drv_cal_sel; 24 + u32 slp_pd_en; 25 + u32 ldo_pd; 26 + }; 16 27 17 28 struct vibra_info { 18 29 struct input_dev *input_dev; 19 30 struct work_struct play_work; 20 31 struct regmap *regmap; 32 + const struct sc27xx_vibra_data *data; 21 33 u32 base; 22 34 u32 strength; 23 35 bool enabled; 24 36 }; 25 37 38 + static const struct sc27xx_vibra_data sc2731_data = { 39 + .cur_drv_cal_sel = CUR_DRV_CAL_SEL, 40 + .slp_pd_en = SLP_LDOVIBR_PD_EN, 41 + .ldo_pd = LDO_VIBR_PD, 42 + }; 43 + 44 + static const struct sc27xx_vibra_data sc2730_data = { 45 + .cur_drv_cal_sel = SC2730_CUR_DRV_CAL_SEL, 46 + .slp_pd_en = SC2730_SLP_LDOVIBR_PD_EN, 47 + .ldo_pd = SC2730_LDO_VIBR_PD, 48 + }; 49 + 50 + static const struct sc27xx_vibra_data sc2721_data = { 51 + .cur_drv_cal_sel = CUR_DRV_CAL_SEL, 52 + .slp_pd_en = SLP_LDOVIBR_PD_EN, 53 + .ldo_pd = LDO_VIBR_PD, 54 + }; 55 + 26 56 static void sc27xx_vibra_set(struct vibra_info *info, bool on) 27 57 { 58 + const struct sc27xx_vibra_data *data = info->data; 28 59 if (on) { 29 - regmap_update_bits(info->regmap, info->base, LDO_VIBR_PD, 0); 60 + regmap_update_bits(info->regmap, info->base, data->ldo_pd, 0); 30 61 regmap_update_bits(info->regmap, info->base, 31 - SLP_LDOVIBR_PD_EN, 0); 62 + data->slp_pd_en, 0); 32 63 info->enabled = true; 33 64 } else { 34 - regmap_update_bits(info->regmap, info->base, LDO_VIBR_PD, 35 - LDO_VIBR_PD); 65 + regmap_update_bits(info->regmap, info->base, data->ldo_pd, 66 + data->ldo_pd); 36 67 regmap_update_bits(info->regmap, info->base, 37 - SLP_LDOVIBR_PD_EN, SLP_LDOVIBR_PD_EN); 68 + data->slp_pd_en, data->slp_pd_en); 38 69 info->enabled = false; 39 70 } 40 71 } 41 72 42 73 static int sc27xx_vibra_hw_init(struct vibra_info *info) 43 74 { 44 - return regmap_update_bits(info->regmap, info->base, CUR_DRV_CAL_SEL, 0); 75 + const struct sc27xx_vibra_data *data = info->data; 76 + 77 + if (!data->cur_drv_cal_sel) 78 + return 0; 79 + 80 + return regmap_update_bits(info->regmap, info->base, 81 + data->cur_drv_cal_sel, 0); 45 82 } 46 83 47 84 static void sc27xx_vibra_play_work(struct work_struct *work) ··· 115 78 static int sc27xx_vibra_probe(struct platform_device *pdev) 116 79 { 117 80 struct vibra_info *info; 81 + const struct sc27xx_vibra_data *data; 118 82 int error; 83 + 84 + data = device_get_match_data(&pdev->dev); 85 + if (!data) { 86 + dev_err(&pdev->dev, "no matching driver data found\n"); 87 + return -EINVAL; 88 + } 119 89 120 90 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); 121 91 if (!info) ··· 149 105 info->input_dev->name = "sc27xx:vibrator"; 150 106 info->input_dev->id.version = 0; 151 107 info->input_dev->close = sc27xx_vibra_close; 108 + info->data = data; 152 109 153 110 input_set_drvdata(info->input_dev, info); 154 111 input_set_capability(info->input_dev, EV_FF, FF_RUMBLE); ··· 179 134 } 180 135 181 136 static const struct of_device_id sc27xx_vibra_of_match[] = { 182 - { .compatible = "sprd,sc2731-vibrator", }, 137 + { .compatible = "sprd,sc2721-vibrator", .data = &sc2721_data }, 138 + { .compatible = "sprd,sc2730-vibrator", .data = &sc2730_data }, 139 + { .compatible = "sprd,sc2731-vibrator", .data = &sc2731_data }, 183 140 {} 184 141 }; 185 142 MODULE_DEVICE_TABLE(of, sc27xx_vibra_of_match);
+1 -1
drivers/input/misc/sirfsoc-onkey.c
··· 181 181 * if users touch X_ONKEY_B, see arch/arm/mach-prima2/pm.c 182 182 */ 183 183 mutex_lock(&input->mutex); 184 - if (input->users) 184 + if (input_device_enabled(input)) 185 185 sirfsoc_pwrc_toggle_interrupts(pwrcdrv, true); 186 186 mutex_unlock(&input->mutex); 187 187
+1 -1
drivers/input/misc/wm831x-on.c
··· 1 - /** 1 + /* 2 2 * wm831x-on.c - WM831X ON pin driver 3 3 * 4 4 * Copyright (C) 2009 Wolfson Microelectronics plc
+1 -1
drivers/input/mouse/Kconfig
··· 372 372 select SERIO 373 373 help 374 374 Say Y (or M) if you want to use a DEC VSXXX-AA (hockey 375 - puck) or a VSXXX-GA (rectangular) mouse. Theses mice are 375 + puck) or a VSXXX-GA (rectangular) mouse. These mice are 376 376 typically used on DECstations or VAXstations, but can also 377 377 be used on any box capable of RS232 (with some adaptor 378 378 described in the source file). This driver also works with the
+8 -10
drivers/input/mouse/cyapa.c
··· 119 119 /** 120 120 * cyapa_i2c_write - Execute i2c block data write operation 121 121 * @cyapa: Handle to this driver 122 - * @ret: Offset of the data to written in the register map 122 + * @reg: Offset of the data to written in the register map 123 123 * @len: number of bytes to write 124 124 * @values: Data to be written 125 125 * ··· 526 526 { 527 527 struct input_dev *input = cyapa->input; 528 528 529 - if (!input || !input->users) { 529 + if (!input || !input_device_enabled(input)) { 530 530 /* 531 531 * When input is NULL, TP must be in deep sleep mode. 532 532 * In this mode, later non-power I2C command will always failed ··· 546 546 { 547 547 struct input_dev *input = cyapa->input; 548 548 549 - if (!input || !input->users) { 549 + if (!input || !input_device_enabled(input)) { 550 550 if (cyapa->gen >= CYAPA_GEN5) 551 551 disable_irq(cyapa->client->irq); 552 552 if (!input || cyapa->operational) ··· 652 652 } 653 653 654 654 out: 655 - if (!input || !input->users) { 655 + if (!input || !input_device_enabled(input)) { 656 656 /* Reset to power OFF state to save power when no user open. */ 657 657 if (cyapa->operational) 658 658 cyapa->ops->set_power_mode(cyapa, ··· 840 840 return error; 841 841 } 842 842 843 - error = devm_add_action(dev, 843 + error = devm_add_action_or_reset(dev, 844 844 cyapa_remove_power_wakeup_group, cyapa); 845 845 if (error) { 846 - cyapa_remove_power_wakeup_group(cyapa); 847 846 dev_err(dev, "failed to add power cleanup action: %d\n", 848 847 error); 849 848 return error; ··· 956 957 return error; 957 958 } 958 959 959 - error = devm_add_action(dev, cyapa_remove_power_runtime_group, cyapa); 960 + error = devm_add_action_or_reset(dev, cyapa_remove_power_runtime_group, 961 + cyapa); 960 962 if (error) { 961 - cyapa_remove_power_runtime_group(cyapa); 962 963 dev_err(dev, 963 964 "failed to add power runtime cleanup action: %d\n", 964 965 error); ··· 1290 1291 return error; 1291 1292 } 1292 1293 1293 - error = devm_add_action(dev, cyapa_disable_regulator, cyapa); 1294 + error = devm_add_action_or_reset(dev, cyapa_disable_regulator, cyapa); 1294 1295 if (error) { 1295 - cyapa_disable_regulator(cyapa); 1296 1296 dev_err(dev, "failed to add disable regulator action: %d\n", 1297 1297 error); 1298 1298 return error;
+2 -1
drivers/input/mouse/cyapa_gen3.c
··· 952 952 * doing so before issuing the next command may result in errors 953 953 * depending on the command's content. 954 954 */ 955 - if (cyapa->operational && input && input->users && 955 + if (cyapa->operational && 956 + input && input_device_enabled(input) && 956 957 (pm_stage == CYAPA_PM_RUNTIME_SUSPEND || 957 958 pm_stage == CYAPA_PM_RUNTIME_RESUME)) { 958 959 /* Try to polling in 120Hz, read may fail, just ignore it. */
+4 -3
drivers/input/mouse/cyapa_gen5.c
··· 385 385 return size; 386 386 } 387 387 388 - /** 388 + /* 389 389 * Return a negative errno code else zero on success. 390 390 */ 391 391 ssize_t cyapa_i2c_pip_write(struct cyapa *cyapa, u8 *buf, size_t size) ··· 435 435 return pm_stage; 436 436 } 437 437 438 - /** 438 + /* 439 439 * This function is aimed to dump all not read data in Gen5 trackpad 440 440 * before send any command, otherwise, the interrupt line will be blocked. 441 441 */ ··· 518 518 *len = length; 519 519 /* Response found, success. */ 520 520 return 0; 521 - } else if (cyapa->operational && input && input->users && 521 + } else if (cyapa->operational && 522 + input && input_device_enabled(input) && 522 523 (pm_stage == CYAPA_PM_RUNTIME_RESUME || 523 524 pm_stage == CYAPA_PM_RUNTIME_SUSPEND)) { 524 525 /* Parse the data and report it if it's valid. */
+1 -1
drivers/input/mouse/cyapa_gen6.c
··· 573 573 574 574 memset(&cmd, 0, sizeof(cmd)); 575 575 put_unaligned_le16(PIP_OUTPUT_REPORT_ADDR, &cmd.head.addr); 576 - put_unaligned_le16(sizeof(cmd), &cmd.head.length - 2); 576 + put_unaligned_le16(sizeof(cmd) - 2, &cmd.head.length); 577 577 cmd.head.report_id = PIP_APP_CMD_REPORT_ID; 578 578 cmd.head.cmd_code = PIP_RETRIEVE_DATA_STRUCTURE; 579 579 put_unaligned_le16(read_offset, &cmd.read_offset);
+16
drivers/input/mouse/elan_i2c.h
··· 28 28 29 29 #define ETP_FEATURE_REPORT_MK BIT(0) 30 30 31 + #define ETP_REPORT_ID 0x5D 32 + #define ETP_TP_REPORT_ID 0x5E 33 + #define ETP_TP_REPORT_ID2 0x5F 34 + #define ETP_REPORT_ID2 0x60 /* High precision report */ 35 + 36 + #define ETP_REPORT_ID_OFFSET 2 37 + #define ETP_TOUCH_INFO_OFFSET 3 38 + #define ETP_FINGER_DATA_OFFSET 4 39 + #define ETP_HOVER_INFO_OFFSET 30 40 + #define ETP_MK_DATA_OFFSET 33 /* For high precision reports */ 41 + 42 + #define ETP_MAX_REPORT_LEN 39 43 + 44 + #define ETP_MAX_FINGERS 5 45 + #define ETP_FINGER_DATA_LEN 5 46 + 31 47 /* IAP Firmware handling */ 32 48 #define ETP_PRODUCT_ID_FORMAT_STRING "%d.0" 33 49 #define ETP_FW_NAME "elan_i2c_" ETP_PRODUCT_ID_FORMAT_STRING ".bin"
+2 -13
drivers/input/mouse/elan_i2c_core.c
··· 34 34 #include <linux/completion.h> 35 35 #include <linux/of.h> 36 36 #include <linux/property.h> 37 - #include <linux/input/elan-i2c-ids.h> 38 37 #include <linux/regulator/consumer.h> 39 38 #include <asm/unaligned.h> 40 39 ··· 45 46 #define ETP_FWIDTH_REDUCE 90 46 47 #define ETP_FINGER_WIDTH 15 47 48 #define ETP_RETRY_COUNT 3 48 - 49 - #define ETP_MAX_FINGERS 5 50 - #define ETP_FINGER_DATA_LEN 5 51 - #define ETP_REPORT_ID 0x5D 52 - #define ETP_REPORT_ID2 0x60 /* High precision report */ 53 - #define ETP_TP_REPORT_ID 0x5E 54 - #define ETP_REPORT_ID_OFFSET 2 55 - #define ETP_TOUCH_INFO_OFFSET 3 56 - #define ETP_FINGER_DATA_OFFSET 4 57 - #define ETP_HOVER_INFO_OFFSET 30 58 - #define ETP_MK_DATA_OFFSET 33 /* For high precision reports */ 59 - #define ETP_MAX_REPORT_LEN 39 60 49 61 50 /* The main device structure */ 62 51 struct elan_tp_data { ··· 1063 1076 elan_report_absolute(data, report, true); 1064 1077 break; 1065 1078 case ETP_TP_REPORT_ID: 1079 + case ETP_TP_REPORT_ID2: 1066 1080 elan_report_trackpoint(data, report); 1067 1081 break; 1068 1082 default: ··· 1402 1414 MODULE_DEVICE_TABLE(i2c, elan_id); 1403 1415 1404 1416 #ifdef CONFIG_ACPI 1417 + #include <linux/input/elan-i2c-ids.h> 1405 1418 MODULE_DEVICE_TABLE(acpi, elan_acpi_id); 1406 1419 #endif 1407 1420
+6 -2
drivers/input/mouse/elan_i2c_smbus.c
··· 45 45 #define ETP_SMBUS_CALIBRATE_QUERY 0xC5 46 46 47 47 #define ETP_SMBUS_REPORT_LEN 32 48 + #define ETP_SMBUS_REPORT_LEN2 7 48 49 #define ETP_SMBUS_REPORT_OFFSET 2 49 50 #define ETP_SMBUS_HELLOPACKET_LEN 5 50 51 #define ETP_SMBUS_IAP_PASSWORD 0x1234 ··· 498 497 return len; 499 498 } 500 499 501 - if (len != ETP_SMBUS_REPORT_LEN) { 500 + if (report[ETP_REPORT_ID_OFFSET] == ETP_TP_REPORT_ID2) 501 + report_len = ETP_SMBUS_REPORT_LEN2; 502 + 503 + if (len != report_len) { 502 504 dev_err(&client->dev, 503 505 "wrong report length (%d vs %d expected)\n", 504 - len, ETP_SMBUS_REPORT_LEN); 506 + len, report_len); 505 507 return -EIO; 506 508 } 507 509
+98 -3
drivers/input/mouse/elantech.c
··· 90 90 } 91 91 92 92 /* 93 + * Send an Elantech style special command to read 3 bytes from a register 94 + */ 95 + static int elantech_read_reg_params(struct psmouse *psmouse, u8 reg, u8 *param) 96 + { 97 + if (elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) || 98 + elantech_ps2_command(psmouse, NULL, ETP_REGISTER_READWRITE) || 99 + elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) || 100 + elantech_ps2_command(psmouse, NULL, reg) || 101 + elantech_ps2_command(psmouse, param, PSMOUSE_CMD_GETINFO)) { 102 + psmouse_err(psmouse, 103 + "failed to read register %#02x\n", reg); 104 + return -EIO; 105 + } 106 + 107 + return 0; 108 + } 109 + 110 + /* 111 + * Send an Elantech style special command to write a register with a parameter 112 + */ 113 + static int elantech_write_reg_params(struct psmouse *psmouse, u8 reg, u8 *param) 114 + { 115 + if (elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) || 116 + elantech_ps2_command(psmouse, NULL, ETP_REGISTER_READWRITE) || 117 + elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) || 118 + elantech_ps2_command(psmouse, NULL, reg) || 119 + elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) || 120 + elantech_ps2_command(psmouse, NULL, param[0]) || 121 + elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) || 122 + elantech_ps2_command(psmouse, NULL, param[1]) || 123 + elantech_ps2_command(psmouse, NULL, PSMOUSE_CMD_SETSCALE11)) { 124 + psmouse_err(psmouse, 125 + "failed to write register %#02x with value %#02x%#02x\n", 126 + reg, param[0], param[1]); 127 + return -EIO; 128 + } 129 + 130 + return 0; 131 + } 132 + 133 + /* 93 134 * Send an Elantech style special command to read a value from a register 94 135 */ 95 136 static int elantech_read_reg(struct psmouse *psmouse, unsigned char reg, ··· 1571 1530 }; 1572 1531 1573 1532 /* 1533 + * Change Report id 0x5E to 0x5F. 1534 + */ 1535 + static int elantech_change_report_id(struct psmouse *psmouse) 1536 + { 1537 + unsigned char param[2] = { 0x10, 0x03 }; 1538 + 1539 + if (elantech_write_reg_params(psmouse, 0x7, param) || 1540 + elantech_read_reg_params(psmouse, 0x7, param) || 1541 + param[0] != 0x10 || param[1] != 0x03) { 1542 + psmouse_err(psmouse, "Unable to change report ID to 0x5f.\n"); 1543 + return -EIO; 1544 + } 1545 + 1546 + return 0; 1547 + } 1548 + /* 1574 1549 * determine hardware version and set some properties according to it. 1575 1550 */ 1576 1551 static int elantech_set_properties(struct elantech_device_info *info) 1577 1552 { 1578 1553 /* This represents the version of IC body. */ 1579 - int ver = (info->fw_version & 0x0f0000) >> 16; 1554 + info->ic_version = (info->fw_version & 0x0f0000) >> 16; 1580 1555 1581 1556 /* Early version of Elan touchpads doesn't obey the rule. */ 1582 1557 if (info->fw_version < 0x020030 || info->fw_version == 0x020600) 1583 1558 info->hw_version = 1; 1584 1559 else { 1585 - switch (ver) { 1560 + switch (info->ic_version) { 1586 1561 case 2: 1587 1562 case 4: 1588 1563 info->hw_version = 2; ··· 1613 1556 return -1; 1614 1557 } 1615 1558 } 1559 + 1560 + /* Get information pattern for hw_version 4 */ 1561 + info->pattern = 0x00; 1562 + if (info->ic_version == 0x0f && (info->fw_version & 0xff) <= 0x02) 1563 + info->pattern = info->fw_version & 0xff; 1616 1564 1617 1565 /* decide which send_cmd we're gonna use early */ 1618 1566 info->send_cmd = info->hw_version >= 3 ? elantech_send_cmd : ··· 1660 1598 { 1661 1599 unsigned char param[3]; 1662 1600 unsigned char traces; 1601 + unsigned char ic_body[3]; 1663 1602 1664 1603 memset(info, 0, sizeof(*info)); 1665 1604 ··· 1703 1640 info->samples[2]); 1704 1641 } 1705 1642 1643 + if (info->pattern > 0x00 && info->ic_version == 0xf) { 1644 + if (info->send_cmd(psmouse, ETP_ICBODY_QUERY, ic_body)) { 1645 + psmouse_err(psmouse, "failed to query ic body\n"); 1646 + return -EINVAL; 1647 + } 1648 + info->ic_version = be16_to_cpup((__be16 *)ic_body); 1649 + psmouse_info(psmouse, 1650 + "Elan ic body: %#04x, current fw version: %#02x\n", 1651 + info->ic_version, ic_body[2]); 1652 + } 1653 + 1654 + info->product_id = be16_to_cpup((__be16 *)info->samples); 1655 + if (info->pattern == 0x00) 1656 + info->product_id &= 0xff; 1657 + 1706 1658 if (info->samples[1] == 0x74 && info->hw_version == 0x03) { 1707 1659 /* 1708 1660 * This module has a bug which makes absolute mode ··· 1731 1653 1732 1654 /* The MSB indicates the presence of the trackpoint */ 1733 1655 info->has_trackpoint = (info->capabilities[0] & 0x80) == 0x80; 1656 + 1657 + if (info->has_trackpoint && info->ic_version == 0x0011 && 1658 + (info->product_id == 0x08 || info->product_id == 0x09 || 1659 + info->product_id == 0x0d || info->product_id == 0x0e)) { 1660 + /* 1661 + * This module has a bug which makes trackpoint in SMBus 1662 + * mode return invalid data unless trackpoint is switched 1663 + * from using 0x5e reports to 0x5f. If we are not able to 1664 + * make the switch, let's abort initialization so we'll be 1665 + * using standard PS/2 protocol. 1666 + */ 1667 + if (elantech_change_report_id(psmouse)) { 1668 + psmouse_info(psmouse, 1669 + "Trackpoint report is broken, forcing standard PS/2 protocol\n"); 1670 + return -ENODEV; 1671 + } 1672 + } 1734 1673 1735 1674 info->x_res = 31; 1736 1675 info->y_res = 31; ··· 1922 1827 leave_breadcrumbs); 1923 1828 } 1924 1829 1925 - /** 1830 + /* 1926 1831 * elantech_setup_smbus - called once the PS/2 devices are enumerated 1927 1832 * and decides to instantiate a SMBus InterTouch device. 1928 1833 */
+4
drivers/input/mouse/elantech.h
··· 18 18 #define ETP_CAPABILITIES_QUERY 0x02 19 19 #define ETP_SAMPLE_QUERY 0x03 20 20 #define ETP_RESOLUTION_QUERY 0x04 21 + #define ETP_ICBODY_QUERY 0x05 21 22 22 23 /* 23 24 * Command values for register reading or writing ··· 141 140 unsigned char samples[3]; 142 141 unsigned char debug; 143 142 unsigned char hw_version; 143 + unsigned char pattern; 144 144 unsigned int fw_version; 145 + unsigned int ic_version; 146 + unsigned int product_id; 145 147 unsigned int x_min; 146 148 unsigned int y_min; 147 149 unsigned int x_max;
+2 -2
drivers/input/mouse/navpoint.c
··· 322 322 struct input_dev *input = navpoint->input; 323 323 324 324 mutex_lock(&input->mutex); 325 - if (input->users) 325 + if (input_device_enabled(input)) 326 326 navpoint_down(navpoint); 327 327 mutex_unlock(&input->mutex); 328 328 ··· 336 336 struct input_dev *input = navpoint->input; 337 337 338 338 mutex_lock(&input->mutex); 339 - if (input->users) 339 + if (input_device_enabled(input)) 340 340 navpoint_up(navpoint); 341 341 mutex_unlock(&input->mutex); 342 342
+1 -1
drivers/input/mouse/synaptics.c
··· 1770 1770 leave_breadcrumbs); 1771 1771 } 1772 1772 1773 - /** 1773 + /* 1774 1774 * synaptics_setup_intertouch - called once the PS/2 devices are enumerated 1775 1775 * and decides to instantiate a SMBus InterTouch device. 1776 1776 */
+1 -1
drivers/input/mouse/vmmouse.c
··· 76 76 char dev_name[128]; 77 77 }; 78 78 79 - /** 79 + /* 80 80 * Hypervisor-specific bi-directional communication channel 81 81 * implementing the vmmouse protocol. Should never execute on 82 82 * bare metal hardware.
+1 -1
drivers/input/rmi4/rmi_bus.c
··· 286 286 /** 287 287 * rmi_register_function_handler - register a handler for an RMI function 288 288 * @handler: RMI handler that should be registered. 289 - * @module: pointer to module that implements the handler 289 + * @owner: pointer to module that implements the handler 290 290 * @mod_name: name of the module implementing the handler 291 291 * 292 292 * This function performs additional setup of RMI function handler and
+9 -7
drivers/input/rmi4/rmi_f01.c
··· 103 103 #define RMI_F01_CTRL0_CONFIGURED_BIT BIT(7) 104 104 105 105 /** 106 - * @ctrl0 - see the bit definitions above. 107 - * @doze_interval - controls the interval between checks for finger presence 108 - * when the touch sensor is in doze mode, in units of 10ms. 109 - * @wakeup_threshold - controls the capacitance threshold at which the touch 110 - * sensor will decide to wake up from that low power state. 111 - * @doze_holdoff - controls how long the touch sensor waits after the last 112 - * finger lifts before entering the doze state, in units of 100ms. 106 + * struct f01_device_control - controls basic sensor functions 107 + * 108 + * @ctrl0: see the bit definitions above. 109 + * @doze_interval: controls the interval between checks for finger presence 110 + * when the touch sensor is in doze mode, in units of 10ms. 111 + * @wakeup_threshold: controls the capacitance threshold at which the touch 112 + * sensor will decide to wake up from that low power state. 113 + * @doze_holdoff: controls how long the touch sensor waits after the last 114 + * finger lifts before entering the doze state, in units of 100ms. 113 115 */ 114 116 struct f01_device_control { 115 117 u8 ctrl0;
+129 -107
drivers/input/rmi4/rmi_f11.c
··· 30 30 #define DEFAULT_MIN_ABS_MT_TRACKING_ID 1 31 31 #define DEFAULT_MAX_ABS_MT_TRACKING_ID 10 32 32 33 - /** A note about RMI4 F11 register structure. 33 + /* 34 + * A note about RMI4 F11 register structure. 34 35 * 35 - * The properties for 36 - * a given sensor are described by its query registers. The number of query 37 - * registers and the layout of their contents are described by the F11 device 38 - * queries as well as the sensor query information. 36 + * The properties for a given sensor are described by its query registers. The 37 + * number of query registers and the layout of their contents are described by 38 + * the F11 device queries as well as the sensor query information. 39 39 * 40 40 * Similarly, each sensor has control registers that govern its behavior. The 41 41 * size and layout of the control registers for a given sensor can be determined ··· 62 62 /* maximum ABS_MT_POSITION displacement (in mm) */ 63 63 #define DMAX 10 64 64 65 - /** 66 - * @rezero - writing this to the F11 command register will cause the sensor to 65 + /* 66 + * Writing this to the F11 command register will cause the sensor to 67 67 * calibrate to the current capacitive state. 68 68 */ 69 69 #define RMI_F11_REZERO 0x01 ··· 178 178 #define F11_UNIFORM_CLICKPAD 0x02 179 179 180 180 /** 181 + * struct f11_2d_sensor_queries - describes sensor capabilities 182 + * 181 183 * Query registers 1 through 4 are always present. 182 184 * 183 - * @nr_fingers - describes the maximum number of fingers the 2-D sensor 184 - * supports. 185 - * @has_rel - the sensor supports relative motion reporting. 186 - * @has_abs - the sensor supports absolute poition reporting. 187 - * @has_gestures - the sensor supports gesture reporting. 188 - * @has_sensitivity_adjust - the sensor supports a global sensitivity 189 - * adjustment. 190 - * @configurable - the sensor supports various configuration options. 191 - * @num_of_x_electrodes - the maximum number of electrodes the 2-D sensor 192 - * supports on the X axis. 193 - * @num_of_y_electrodes - the maximum number of electrodes the 2-D sensor 194 - * supports on the Y axis. 195 - * @max_electrodes - the total number of X and Y electrodes that may be 196 - * configured. 185 + * @nr_fingers: describes the maximum number of fingers the 2-D sensor 186 + * supports. 187 + * @has_rel: the sensor supports relative motion reporting. 188 + * @has_abs: the sensor supports absolute poition reporting. 189 + * @has_gestures: the sensor supports gesture reporting. 190 + * @has_sensitivity_adjust: the sensor supports a global sensitivity 191 + * adjustment. 192 + * @configurable: the sensor supports various configuration options. 193 + * @nr_x_electrodes: the maximum number of electrodes the 2-D sensor 194 + * supports on the X axis. 195 + * @nr_y_electrodes: the maximum number of electrodes the 2-D sensor 196 + * supports on the Y axis. 197 + * @max_electrodes: the total number of X and Y electrodes that may be 198 + * configured. 197 199 * 198 200 * Query 5 is present if the has_abs bit is set. 199 201 * 200 - * @abs_data_size - describes the format of data reported by the absolute 201 - * data source. Only one format (the kind used here) is supported at this 202 - * time. 203 - * @has_anchored_finger - then the sensor supports the high-precision second 204 - * finger tracking provided by the manual tracking and motion sensitivity 205 - * options. 206 - * @has_adjust_hyst - the difference between the finger release threshold and 207 - * the touch threshold. 208 - * @has_dribble - the sensor supports the generation of dribble interrupts, 209 - * which may be enabled or disabled with the dribble control bit. 210 - * @has_bending_correction - Bending related data registers 28 and 36, and 211 - * control register 52..57 are present. 212 - * @has_large_object_suppression - control register 58 and data register 28 213 - * exist. 214 - * @has_jitter_filter - query 13 and control 73..76 exist. 202 + * @abs_data_size: describes the format of data reported by the absolute 203 + * data source. Only one format (the kind used here) is supported at this 204 + * time. 205 + * @has_anchored_finger: then the sensor supports the high-precision second 206 + * finger tracking provided by the manual tracking and motion sensitivity 207 + * options. 208 + * @has_adj_hyst: the difference between the finger release threshold and 209 + * the touch threshold. 210 + * @has_dribble: the sensor supports the generation of dribble interrupts, 211 + * which may be enabled or disabled with the dribble control bit. 212 + * @has_bending_correction: Bending related data registers 28 and 36, and 213 + * control register 52..57 are present. 214 + * @has_large_object_suppression: control register 58 and data register 28 215 + * exist. 216 + * @has_jitter_filter: query 13 and control 73..76 exist. 217 + * 218 + * Query 6 is present if the has_rel it is set. 219 + * 220 + * @f11_2d_query6: this register is reserved. 215 221 * 216 222 * Gesture information queries 7 and 8 are present if has_gestures bit is set. 217 223 * 218 - * @has_single_tap - a basic single-tap gesture is supported. 219 - * @has_tap_n_hold - tap-and-hold gesture is supported. 220 - * @has_double_tap - double-tap gesture is supported. 221 - * @has_early_tap - early tap is supported and reported as soon as the finger 222 - * lifts for any tap event that could be interpreted as either a single tap 223 - * or as the first tap of a double-tap or tap-and-hold gesture. 224 - * @has_flick - flick detection is supported. 225 - * @has_press - press gesture reporting is supported. 226 - * @has_pinch - pinch gesture detection is supported. 227 - * @has_palm_det - the 2-D sensor notifies the host whenever a large conductive 228 - * object such as a palm or a cheek touches the 2-D sensor. 229 - * @has_rotate - rotation gesture detection is supported. 230 - * @has_touch_shapes - TouchShapes are supported. A TouchShape is a fixed 231 - * rectangular area on the sensor that behaves like a capacitive button. 232 - * @has_scroll_zones - scrolling areas near the sensor edges are supported. 233 - * @has_individual_scroll_zones - if 1, then 4 scroll zones are supported; 234 - * if 0, then only two are supported. 235 - * @has_mf_scroll - the multifinger_scrolling bit will be set when 236 - * more than one finger is involved in a scrolling action. 224 + * @has_single_tap: a basic single-tap gesture is supported. 225 + * @has_tap_n_hold: tap-and-hold gesture is supported. 226 + * @has_double_tap: double-tap gesture is supported. 227 + * @has_early_tap: early tap is supported and reported as soon as the finger 228 + * lifts for any tap event that could be interpreted as either a single 229 + * tap or as the first tap of a double-tap or tap-and-hold gesture. 230 + * @has_flick: flick detection is supported. 231 + * @has_press: press gesture reporting is supported. 232 + * @has_pinch: pinch gesture detection is supported. 233 + * @has_chiral: chiral (circular) scrolling gesture detection is supported. 234 + * @has_palm_det: the 2-D sensor notifies the host whenever a large conductive 235 + * object such as a palm or a cheek touches the 2-D sensor. 236 + * @has_rotate: rotation gesture detection is supported. 237 + * @has_touch_shapes: TouchShapes are supported. A TouchShape is a fixed 238 + * rectangular area on the sensor that behaves like a capacitive button. 239 + * @has_scroll_zones: scrolling areas near the sensor edges are supported. 240 + * @has_individual_scroll_zones: if 1, then 4 scroll zones are supported; 241 + * if 0, then only two are supported. 242 + * @has_mf_scroll: the multifinger_scrolling bit will be set when 243 + * more than one finger is involved in a scrolling action. 244 + * @has_mf_edge_motion: indicates whether multi-finger edge motion gesture 245 + * is supported. 246 + * @has_mf_scroll_inertia: indicates whether multi-finger scroll inertia 247 + * feature is supported. 237 248 * 238 249 * Convenience for checking bytes in the gesture info registers. This is done 239 250 * often enough that we put it here to declutter the conditionals 240 251 * 241 - * @query7_nonzero - true if none of the query 7 bits are set 242 - * @query8_nonzero - true if none of the query 8 bits are set 252 + * @query7_nonzero: true if none of the query 7 bits are set 253 + * @query8_nonzero: true if none of the query 8 bits are set 243 254 * 244 255 * Query 9 is present if the has_query9 is set. 245 256 * 246 - * @has_pen - detection of a stylus is supported and registers F11_2D_Ctrl20 247 - * and F11_2D_Ctrl21 exist. 248 - * @has_proximity - detection of fingers near the sensor is supported and 249 - * registers F11_2D_Ctrl22 through F11_2D_Ctrl26 exist. 250 - * @has_palm_det_sensitivity - the sensor supports the palm detect sensitivity 251 - * feature and register F11_2D_Ctrl27 exists. 252 - * @has_two_pen_thresholds - is has_pen is also set, then F11_2D_Ctrl35 exists. 253 - * @has_contact_geometry - the sensor supports the use of contact geometry to 254 - * map absolute X and Y target positions and registers F11_2D_Data18 255 - * through F11_2D_Data27 exist. 257 + * @has_pen: detection of a stylus is supported and registers F11_2D_Ctrl20 258 + * and F11_2D_Ctrl21 exist. 259 + * @has_proximity: detection of fingers near the sensor is supported and 260 + * registers F11_2D_Ctrl22 through F11_2D_Ctrl26 exist. 261 + * @has_palm_det_sensitivity: the sensor supports the palm detect sensitivity 262 + * feature and register F11_2D_Ctrl27 exists. 263 + * @has_suppress_on_palm_detect: the device supports the large object detect 264 + * suppression feature and register F11_2D_Ctrl27 exists. 265 + * @has_two_pen_thresholds: if has_pen is also set, then F11_2D_Ctrl35 exists. 266 + * @has_contact_geometry: the sensor supports the use of contact geometry to 267 + * map absolute X and Y target positions and registers F11_2D_Data18 268 + * through F11_2D_Data27 exist. 269 + * @has_pen_hover_discrimination: if has_pen is also set, then registers 270 + * F11_2D_Data29 through F11_2D_Data31, F11_2D_Ctrl68.*, F11_2D_Ctrl69 271 + * and F11_2D_Ctrl72 exist. 272 + * @has_pen_filters: if has_pen is also set, then registers F11_2D_Ctrl70 and 273 + * F11_2D_Ctrl71 exist. 256 274 * 257 275 * Touch shape info (query 10) is present if has_touch_shapes is set. 258 276 * 259 - * @nr_touch_shapes - the total number of touch shapes supported. 277 + * @nr_touch_shapes: the total number of touch shapes supported. 260 278 * 261 279 * Query 11 is present if the has_query11 bit is set in query 0. 262 280 * 263 - * @has_z_tuning - if set, the sensor supports Z tuning and registers 264 - * F11_2D_Ctrl29 through F11_2D_Ctrl33 exist. 265 - * @has_algorithm_selection - controls choice of noise suppression algorithm 266 - * @has_w_tuning - the sensor supports Wx and Wy scaling and registers 267 - * F11_2D_Ctrl36 through F11_2D_Ctrl39 exist. 268 - * @has_pitch_info - the X and Y pitches of the sensor electrodes can be 269 - * configured and registers F11_2D_Ctrl40 and F11_2D_Ctrl41 exist. 270 - * @has_finger_size - the default finger width settings for the 271 - * sensor can be configured and registers F11_2D_Ctrl42 through F11_2D_Ctrl44 272 - * exist. 273 - * @has_segmentation_aggressiveness - the sensor’s ability to distinguish 274 - * multiple objects close together can be configured and register F11_2D_Ctrl45 275 - * exists. 276 - * @has_XY_clip - the inactive outside borders of the sensor can be 277 - * configured and registers F11_2D_Ctrl46 through F11_2D_Ctrl49 exist. 278 - * @has_drumming_filter - the sensor can be configured to distinguish 279 - * between a fast flick and a quick drumming movement and registers 280 - * F11_2D_Ctrl50 and F11_2D_Ctrl51 exist. 281 + * @has_z_tuning: if set, the sensor supports Z tuning and registers 282 + * F11_2D_Ctrl29 through F11_2D_Ctrl33 exist. 283 + * @has_algorithm_selection: controls choice of noise suppression algorithm 284 + * @has_w_tuning: the sensor supports Wx and Wy scaling and registers 285 + * F11_2D_Ctrl36 through F11_2D_Ctrl39 exist. 286 + * @has_pitch_info: the X and Y pitches of the sensor electrodes can be 287 + * configured and registers F11_2D_Ctrl40 and F11_2D_Ctrl41 exist. 288 + * @has_finger_size: the default finger width settings for the sensor 289 + * can be configured and registers F11_2D_Ctrl42 through F11_2D_Ctrl44 290 + * exist. 291 + * @has_segmentation_aggressiveness: the sensor’s ability to distinguish 292 + * multiple objects close together can be configured and register 293 + * F11_2D_Ctrl45 exists. 294 + * @has_XY_clip: the inactive outside borders of the sensor can be 295 + * configured and registers F11_2D_Ctrl46 through F11_2D_Ctrl49 exist. 296 + * @has_drumming_filter: the sensor can be configured to distinguish 297 + * between a fast flick and a quick drumming movement and registers 298 + * F11_2D_Ctrl50 and F11_2D_Ctrl51 exist. 281 299 * 282 300 * Query 12 is present if hasQuery12 bit is set. 283 301 * 284 - * @has_gapless_finger - control registers relating to gapless finger are 285 - * present. 286 - * @has_gapless_finger_tuning - additional control and data registers relating 287 - * to gapless finger are present. 288 - * @has_8bit_w - larger W value reporting is supported. 289 - * @has_adjustable_mapping - TBD 290 - * @has_info2 - the general info query14 is present 291 - * @has_physical_props - additional queries describing the physical properties 292 - * of the sensor are present. 293 - * @has_finger_limit - indicates that F11 Ctrl 80 exists. 294 - * @has_linear_coeff - indicates that F11 Ctrl 81 exists. 302 + * @has_gapless_finger: control registers relating to gapless finger are 303 + * present. 304 + * @has_gapless_finger_tuning: additional control and data registers relating 305 + * to gapless finger are present. 306 + * @has_8bit_w: larger W value reporting is supported. 307 + * @has_adjustable_mapping: TBD 308 + * @has_info2: the general info query14 is present 309 + * @has_physical_props: additional queries describing the physical properties 310 + * of the sensor are present. 311 + * @has_finger_limit: indicates that F11 Ctrl 80 exists. 312 + * @has_linear_coeff_2: indicates that F11 Ctrl 81 exists. 295 313 * 296 314 * Query 13 is present if Query 5's has_jitter_filter bit is set. 297 - * @jitter_window_size - used by Design Studio 4. 298 - * @jitter_filter_type - used by Design Studio 4. 315 + * 316 + * @jitter_window_size: used by Design Studio 4. 317 + * @jitter_filter_type: used by Design Studio 4. 299 318 * 300 319 * Query 14 is present if query 12's has_general_info2 flag is set. 301 320 * 302 - * @light_control - Indicates what light/led control features are present, if 303 - * any. 304 - * @is_clear - if set, this is a clear sensor (indicating direct pointing 305 - * application), otherwise it's opaque (indicating indirect pointing). 306 - * @clickpad_props - specifies if this is a clickpad, and if so what sort of 307 - * mechanism it uses 308 - * @mouse_buttons - specifies the number of mouse buttons present (if any). 309 - * @has_advanced_gestures - advanced driver gestures are supported. 321 + * @light_control: Indicates what light/led control features are present, 322 + * if any. 323 + * @is_clear: if set, this is a clear sensor (indicating direct pointing 324 + * application), otherwise it's opaque (indicating indirect pointing). 325 + * @clickpad_props: specifies if this is a clickpad, and if so what sort of 326 + * mechanism it uses 327 + * @mouse_buttons: specifies the number of mouse buttons present (if any). 328 + * @has_advanced_gestures: advanced driver gestures are supported. 329 + * 330 + * @x_sensor_size_mm: size of the sensor in millimeters on the X axis. 331 + * @y_sensor_size_mm: size of the sensor in millimeters on the Y axis. 310 332 */ 311 333 struct f11_2d_sensor_queries { 312 334 /* query1 */
+6
drivers/input/rmi4/rmi_f54.c
··· 42 42 /** 43 43 * enum rmi_f54_report_type - RMI4 F54 report types 44 44 * 45 + * @F54_REPORT_NONE: No Image Report. 46 + * 45 47 * @F54_8BIT_IMAGE: Normalized 8-Bit Image Report. The capacitance variance 46 48 * from baseline for each pixel. 47 49 * ··· 66 64 * Report. Set Low reference to its minimum value and high 67 65 * references to its maximum value, then report the raw 68 66 * capacitance for each pixel. 67 + * 68 + * @F54_MAX_REPORT_TYPE: 69 + * Maximum number of Report Types. Used for sanity 70 + * checking. 69 71 */ 70 72 enum rmi_f54_report_type { 71 73 F54_REPORT_NONE = 0,
+4
drivers/input/rmi4/rmi_i2c.c
··· 17 17 * struct rmi_i2c_xport - stores information for i2c communication 18 18 * 19 19 * @xport: The transport interface structure 20 + * @client: The I2C client device structure 20 21 * 21 22 * @page_mutex: Locks current page to avoid changing pages in unexpected ways. 22 23 * @page: Keeps track of the current virtual page 23 24 * 24 25 * @tx_buf: Buffer used for transmitting data to the sensor over i2c. 25 26 * @tx_buf_size: Size of the buffer 27 + * 28 + * @supplies: Array of voltage regulators 29 + * @startup_delay: Milliseconds to pause after powering up the regulators 26 30 */ 27 31 struct rmi_i2c_xport { 28 32 struct rmi_transport_dev xport;
+4 -2
drivers/input/rmi4/rmi_spi.c
··· 188 188 memset(xfer, 0, sizeof(struct spi_transfer)); 189 189 xfer->tx_buf = &rmi_spi->tx_buf[i]; 190 190 xfer->len = 1; 191 - xfer->delay_usecs = spi_data->write_delay_us; 191 + xfer->delay.value = spi_data->write_delay_us; 192 + xfer->delay.unit = SPI_DELAY_UNIT_USECS; 192 193 spi_message_add_tail(xfer, &msg); 193 194 } 194 195 } else { ··· 211 210 memset(xfer, 0, sizeof(struct spi_transfer)); 212 211 xfer->rx_buf = &rmi_spi->rx_buf[i]; 213 212 xfer->len = 1; 214 - xfer->delay_usecs = spi_data->read_delay_us; 213 + xfer->delay.value = spi_data->read_delay_us; 214 + xfer->delay.unit = SPI_DELAY_UNIT_USECS; 215 215 spi_message_add_tail(xfer, &msg); 216 216 } 217 217 } else {
+1 -1
drivers/input/serio/libps2.c
··· 405 405 ps2dev->nak = PS2_RET_ERR; 406 406 break; 407 407 } 408 - /* Fall through */ 408 + fallthrough; 409 409 410 410 /* 411 411 * Workaround for mice which don't ACK the Get ID command.
+1 -1
drivers/input/serio/parkbd.c
··· 168 168 serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 169 169 if (serio) { 170 170 serio->id.type = parkbd_mode; 171 - serio->write = parkbd_write, 171 + serio->write = parkbd_write; 172 172 strlcpy(serio->name, "PARKBD AT/XT keyboard adapter", sizeof(serio->name)); 173 173 snprintf(serio->phys, sizeof(serio->phys), "%s/serio0", parkbd_dev->port->name); 174 174 }
-12
drivers/input/tablet/Kconfig
··· 38 38 To compile this driver as a module, choose M here: the 39 39 module will be called aiptek. 40 40 41 - config TABLET_USB_GTCO 42 - tristate "GTCO CalComp/InterWrite USB Support" 43 - depends on USB && INPUT 44 - help 45 - Say Y here if you want to use the USB version of the GTCO 46 - CalComp/InterWrite Tablet. Make sure to say Y to "Mouse support" 47 - (CONFIG_INPUT_MOUSEDEV) and/or "Event interface support" 48 - (CONFIG_INPUT_EVDEV) as well. 49 - 50 - To compile this driver as a module, choose M here: the 51 - module will be called gtco. 52 - 53 41 config TABLET_USB_HANWANG 54 42 tristate "Hanwang Art Master III tablet support (USB)" 55 43 depends on USB_ARCH_HAS_HCD
-1
drivers/input/tablet/Makefile
··· 6 6 7 7 obj-$(CONFIG_TABLET_USB_ACECAD) += acecad.o 8 8 obj-$(CONFIG_TABLET_USB_AIPTEK) += aiptek.o 9 - obj-$(CONFIG_TABLET_USB_GTCO) += gtco.o 10 9 obj-$(CONFIG_TABLET_USB_HANWANG) += hanwang.o 11 10 obj-$(CONFIG_TABLET_USB_KBTAB) += kbtab.o 12 11 obj-$(CONFIG_TABLET_USB_PEGASUS) += pegasus_notetaker.o
-1043
drivers/input/tablet/gtco.c
··· 1 - /* -*- linux-c -*- 2 - 3 - GTCO digitizer USB driver 4 - 5 - TO CHECK: Is pressure done right on report 5? 6 - 7 - Copyright (C) 2006 GTCO CalComp 8 - 9 - This program is free software; you can redistribute it and/or 10 - modify it under the terms of the GNU General Public License 11 - as published by the Free Software Foundation; version 2 12 - of the License. 13 - 14 - This program is distributed in the hope that it will be useful, 15 - but WITHOUT ANY WARRANTY; without even the implied warranty of 16 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 - GNU General Public License for more details. 18 - 19 - You should have received a copy of the GNU General Public License 20 - along with this program; if not, write to the Free Software 21 - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 - 23 - Permission to use, copy, modify, distribute, and sell this software and its 24 - documentation for any purpose is hereby granted without fee, provided that 25 - the above copyright notice appear in all copies and that both that 26 - copyright notice and this permission notice appear in supporting 27 - documentation, and that the name of GTCO-CalComp not be used in advertising 28 - or publicity pertaining to distribution of the software without specific, 29 - written prior permission. GTCO-CalComp makes no representations about the 30 - suitability of this software for any purpose. It is provided "as is" 31 - without express or implied warranty. 32 - 33 - GTCO-CALCOMP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 34 - INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 35 - EVENT SHALL GTCO-CALCOMP BE LIABLE FOR ANY SPECIAL, INDIRECT OR 36 - CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 37 - DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 38 - TORTIOUS ACTIONS, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 39 - PERFORMANCE OF THIS SOFTWARE. 40 - 41 - GTCO CalComp, Inc. 42 - 7125 Riverwood Drive 43 - Columbia, MD 21046 44 - 45 - Jeremy Roberson jroberson@gtcocalcomp.com 46 - Scott Hill shill@gtcocalcomp.com 47 - */ 48 - 49 - 50 - 51 - /*#define DEBUG*/ 52 - 53 - #include <linux/kernel.h> 54 - #include <linux/module.h> 55 - #include <linux/errno.h> 56 - #include <linux/slab.h> 57 - #include <linux/input.h> 58 - #include <linux/usb.h> 59 - #include <linux/uaccess.h> 60 - #include <asm/unaligned.h> 61 - #include <asm/byteorder.h> 62 - #include <linux/bitops.h> 63 - 64 - #include <linux/usb/input.h> 65 - 66 - /* Version with a Major number of 2 is for kernel inclusion only. */ 67 - #define GTCO_VERSION "2.00.0006" 68 - 69 - 70 - /* MACROS */ 71 - 72 - #define VENDOR_ID_GTCO 0x078C 73 - #define PID_400 0x400 74 - #define PID_401 0x401 75 - #define PID_1000 0x1000 76 - #define PID_1001 0x1001 77 - #define PID_1002 0x1002 78 - 79 - /* Max size of a single report */ 80 - #define REPORT_MAX_SIZE 10 81 - #define MAX_COLLECTION_LEVELS 10 82 - 83 - 84 - /* Bitmask whether pen is in range */ 85 - #define MASK_INRANGE 0x20 86 - #define MASK_BUTTON 0x01F 87 - 88 - #define PATHLENGTH 64 89 - 90 - /* DATA STRUCTURES */ 91 - 92 - /* Device table */ 93 - static const struct usb_device_id gtco_usbid_table[] = { 94 - { USB_DEVICE(VENDOR_ID_GTCO, PID_400) }, 95 - { USB_DEVICE(VENDOR_ID_GTCO, PID_401) }, 96 - { USB_DEVICE(VENDOR_ID_GTCO, PID_1000) }, 97 - { USB_DEVICE(VENDOR_ID_GTCO, PID_1001) }, 98 - { USB_DEVICE(VENDOR_ID_GTCO, PID_1002) }, 99 - { } 100 - }; 101 - MODULE_DEVICE_TABLE (usb, gtco_usbid_table); 102 - 103 - 104 - /* Structure to hold all of our device specific stuff */ 105 - struct gtco { 106 - 107 - struct input_dev *inputdevice; /* input device struct pointer */ 108 - struct usb_interface *intf; /* the usb interface for this device */ 109 - struct urb *urbinfo; /* urb for incoming reports */ 110 - dma_addr_t buf_dma; /* dma addr of the data buffer*/ 111 - unsigned char * buffer; /* databuffer for reports */ 112 - 113 - char usbpath[PATHLENGTH]; 114 - int openCount; 115 - 116 - /* Information pulled from Report Descriptor */ 117 - u32 usage; 118 - u32 min_X; 119 - u32 max_X; 120 - u32 min_Y; 121 - u32 max_Y; 122 - s8 mintilt_X; 123 - s8 maxtilt_X; 124 - s8 mintilt_Y; 125 - s8 maxtilt_Y; 126 - u32 maxpressure; 127 - u32 minpressure; 128 - }; 129 - 130 - 131 - 132 - /* Code for parsing the HID REPORT DESCRIPTOR */ 133 - 134 - /* From HID1.11 spec */ 135 - struct hid_descriptor 136 - { 137 - struct usb_descriptor_header header; 138 - __le16 bcdHID; 139 - u8 bCountryCode; 140 - u8 bNumDescriptors; 141 - u8 bDescriptorType; 142 - __le16 wDescriptorLength; 143 - } __attribute__ ((packed)); 144 - 145 - 146 - #define HID_DESCRIPTOR_SIZE 9 147 - #define HID_DEVICE_TYPE 33 148 - #define REPORT_DEVICE_TYPE 34 149 - 150 - 151 - #define PREF_TAG(x) ((x)>>4) 152 - #define PREF_TYPE(x) ((x>>2)&0x03) 153 - #define PREF_SIZE(x) ((x)&0x03) 154 - 155 - #define TYPE_MAIN 0 156 - #define TYPE_GLOBAL 1 157 - #define TYPE_LOCAL 2 158 - #define TYPE_RESERVED 3 159 - 160 - #define TAG_MAIN_INPUT 0x8 161 - #define TAG_MAIN_OUTPUT 0x9 162 - #define TAG_MAIN_FEATURE 0xB 163 - #define TAG_MAIN_COL_START 0xA 164 - #define TAG_MAIN_COL_END 0xC 165 - 166 - #define TAG_GLOB_USAGE 0 167 - #define TAG_GLOB_LOG_MIN 1 168 - #define TAG_GLOB_LOG_MAX 2 169 - #define TAG_GLOB_PHYS_MIN 3 170 - #define TAG_GLOB_PHYS_MAX 4 171 - #define TAG_GLOB_UNIT_EXP 5 172 - #define TAG_GLOB_UNIT 6 173 - #define TAG_GLOB_REPORT_SZ 7 174 - #define TAG_GLOB_REPORT_ID 8 175 - #define TAG_GLOB_REPORT_CNT 9 176 - #define TAG_GLOB_PUSH 10 177 - #define TAG_GLOB_POP 11 178 - 179 - #define TAG_GLOB_MAX 12 180 - 181 - #define DIGITIZER_USAGE_TIP_PRESSURE 0x30 182 - #define DIGITIZER_USAGE_TILT_X 0x3D 183 - #define DIGITIZER_USAGE_TILT_Y 0x3E 184 - 185 - 186 - /* 187 - * This is an abbreviated parser for the HID Report Descriptor. We 188 - * know what devices we are talking to, so this is by no means meant 189 - * to be generic. We can make some safe assumptions: 190 - * 191 - * - We know there are no LONG tags, all short 192 - * - We know that we have no MAIN Feature and MAIN Output items 193 - * - We know what the IRQ reports are supposed to look like. 194 - * 195 - * The main purpose of this is to use the HID report desc to figure 196 - * out the mins and maxs of the fields in the IRQ reports. The IRQ 197 - * reports for 400/401 change slightly if the max X is bigger than 64K. 198 - * 199 - */ 200 - static void parse_hid_report_descriptor(struct gtco *device, char * report, 201 - int length) 202 - { 203 - struct device *ddev = &device->intf->dev; 204 - int x, i = 0; 205 - 206 - /* Tag primitive vars */ 207 - __u8 prefix; 208 - __u8 size; 209 - __u8 tag; 210 - __u8 type; 211 - __u8 data = 0; 212 - __u16 data16 = 0; 213 - __u32 data32 = 0; 214 - 215 - /* For parsing logic */ 216 - int inputnum = 0; 217 - __u32 usage = 0; 218 - 219 - /* Global Values, indexed by TAG */ 220 - __u32 globalval[TAG_GLOB_MAX]; 221 - __u32 oldval[TAG_GLOB_MAX]; 222 - 223 - /* Debug stuff */ 224 - char maintype = 'x'; 225 - char globtype[12]; 226 - int indent = 0; 227 - char indentstr[MAX_COLLECTION_LEVELS + 1] = { 0 }; 228 - 229 - dev_dbg(ddev, "======>>>>>>PARSE<<<<<<======\n"); 230 - 231 - /* Walk this report and pull out the info we need */ 232 - while (i < length) { 233 - prefix = report[i++]; 234 - 235 - /* Determine data size and save the data in the proper variable */ 236 - size = (1U << PREF_SIZE(prefix)) >> 1; 237 - if (i + size > length) { 238 - dev_err(ddev, 239 - "Not enough data (need %d, have %d)\n", 240 - i + size, length); 241 - break; 242 - } 243 - 244 - switch (size) { 245 - case 1: 246 - data = report[i]; 247 - break; 248 - case 2: 249 - data16 = get_unaligned_le16(&report[i]); 250 - break; 251 - case 4: 252 - data32 = get_unaligned_le32(&report[i]); 253 - break; 254 - } 255 - 256 - /* Skip size of data */ 257 - i += size; 258 - 259 - /* What we do depends on the tag type */ 260 - tag = PREF_TAG(prefix); 261 - type = PREF_TYPE(prefix); 262 - switch (type) { 263 - case TYPE_MAIN: 264 - strcpy(globtype, ""); 265 - switch (tag) { 266 - 267 - case TAG_MAIN_INPUT: 268 - /* 269 - * The INPUT MAIN tag signifies this is 270 - * information from a report. We need to 271 - * figure out what it is and store the 272 - * min/max values 273 - */ 274 - 275 - maintype = 'I'; 276 - if (data == 2) 277 - strcpy(globtype, "Variable"); 278 - else if (data == 3) 279 - strcpy(globtype, "Var|Const"); 280 - 281 - dev_dbg(ddev, "::::: Saving Report: %d input #%d Max: 0x%X(%d) Min:0x%X(%d) of %d bits\n", 282 - globalval[TAG_GLOB_REPORT_ID], inputnum, 283 - globalval[TAG_GLOB_LOG_MAX], globalval[TAG_GLOB_LOG_MAX], 284 - globalval[TAG_GLOB_LOG_MIN], globalval[TAG_GLOB_LOG_MIN], 285 - globalval[TAG_GLOB_REPORT_SZ] * globalval[TAG_GLOB_REPORT_CNT]); 286 - 287 - 288 - /* 289 - We can assume that the first two input items 290 - are always the X and Y coordinates. After 291 - that, we look for everything else by 292 - local usage value 293 - */ 294 - switch (inputnum) { 295 - case 0: /* X coord */ 296 - dev_dbg(ddev, "GER: X Usage: 0x%x\n", usage); 297 - if (device->max_X == 0) { 298 - device->max_X = globalval[TAG_GLOB_LOG_MAX]; 299 - device->min_X = globalval[TAG_GLOB_LOG_MIN]; 300 - } 301 - break; 302 - 303 - case 1: /* Y coord */ 304 - dev_dbg(ddev, "GER: Y Usage: 0x%x\n", usage); 305 - if (device->max_Y == 0) { 306 - device->max_Y = globalval[TAG_GLOB_LOG_MAX]; 307 - device->min_Y = globalval[TAG_GLOB_LOG_MIN]; 308 - } 309 - break; 310 - 311 - default: 312 - /* Tilt X */ 313 - if (usage == DIGITIZER_USAGE_TILT_X) { 314 - if (device->maxtilt_X == 0) { 315 - device->maxtilt_X = globalval[TAG_GLOB_LOG_MAX]; 316 - device->mintilt_X = globalval[TAG_GLOB_LOG_MIN]; 317 - } 318 - } 319 - 320 - /* Tilt Y */ 321 - if (usage == DIGITIZER_USAGE_TILT_Y) { 322 - if (device->maxtilt_Y == 0) { 323 - device->maxtilt_Y = globalval[TAG_GLOB_LOG_MAX]; 324 - device->mintilt_Y = globalval[TAG_GLOB_LOG_MIN]; 325 - } 326 - } 327 - 328 - /* Pressure */ 329 - if (usage == DIGITIZER_USAGE_TIP_PRESSURE) { 330 - if (device->maxpressure == 0) { 331 - device->maxpressure = globalval[TAG_GLOB_LOG_MAX]; 332 - device->minpressure = globalval[TAG_GLOB_LOG_MIN]; 333 - } 334 - } 335 - 336 - break; 337 - } 338 - 339 - inputnum++; 340 - break; 341 - 342 - case TAG_MAIN_OUTPUT: 343 - maintype = 'O'; 344 - break; 345 - 346 - case TAG_MAIN_FEATURE: 347 - maintype = 'F'; 348 - break; 349 - 350 - case TAG_MAIN_COL_START: 351 - maintype = 'S'; 352 - 353 - if (indent == MAX_COLLECTION_LEVELS) { 354 - dev_err(ddev, "Collection level %d would exceed limit of %d\n", 355 - indent + 1, 356 - MAX_COLLECTION_LEVELS); 357 - break; 358 - } 359 - 360 - if (data == 0) { 361 - dev_dbg(ddev, "======>>>>>> Physical\n"); 362 - strcpy(globtype, "Physical"); 363 - } else 364 - dev_dbg(ddev, "======>>>>>>\n"); 365 - 366 - /* Indent the debug output */ 367 - indent++; 368 - for (x = 0; x < indent; x++) 369 - indentstr[x] = '-'; 370 - indentstr[x] = 0; 371 - 372 - /* Save global tags */ 373 - for (x = 0; x < TAG_GLOB_MAX; x++) 374 - oldval[x] = globalval[x]; 375 - 376 - break; 377 - 378 - case TAG_MAIN_COL_END: 379 - maintype = 'E'; 380 - 381 - if (indent == 0) { 382 - dev_err(ddev, "Collection level already at zero\n"); 383 - break; 384 - } 385 - 386 - dev_dbg(ddev, "<<<<<<======\n"); 387 - 388 - indent--; 389 - for (x = 0; x < indent; x++) 390 - indentstr[x] = '-'; 391 - indentstr[x] = 0; 392 - 393 - /* Copy global tags back */ 394 - for (x = 0; x < TAG_GLOB_MAX; x++) 395 - globalval[x] = oldval[x]; 396 - 397 - break; 398 - } 399 - 400 - switch (size) { 401 - case 1: 402 - dev_dbg(ddev, "%sMAINTAG:(%d) %c SIZE: %d Data: %s 0x%x\n", 403 - indentstr, tag, maintype, size, globtype, data); 404 - break; 405 - 406 - case 2: 407 - dev_dbg(ddev, "%sMAINTAG:(%d) %c SIZE: %d Data: %s 0x%x\n", 408 - indentstr, tag, maintype, size, globtype, data16); 409 - break; 410 - 411 - case 4: 412 - dev_dbg(ddev, "%sMAINTAG:(%d) %c SIZE: %d Data: %s 0x%x\n", 413 - indentstr, tag, maintype, size, globtype, data32); 414 - break; 415 - } 416 - break; 417 - 418 - case TYPE_GLOBAL: 419 - switch (tag) { 420 - case TAG_GLOB_USAGE: 421 - /* 422 - * First time we hit the global usage tag, 423 - * it should tell us the type of device 424 - */ 425 - if (device->usage == 0) 426 - device->usage = data; 427 - 428 - strcpy(globtype, "USAGE"); 429 - break; 430 - 431 - case TAG_GLOB_LOG_MIN: 432 - strcpy(globtype, "LOG_MIN"); 433 - break; 434 - 435 - case TAG_GLOB_LOG_MAX: 436 - strcpy(globtype, "LOG_MAX"); 437 - break; 438 - 439 - case TAG_GLOB_PHYS_MIN: 440 - strcpy(globtype, "PHYS_MIN"); 441 - break; 442 - 443 - case TAG_GLOB_PHYS_MAX: 444 - strcpy(globtype, "PHYS_MAX"); 445 - break; 446 - 447 - case TAG_GLOB_UNIT_EXP: 448 - strcpy(globtype, "EXP"); 449 - break; 450 - 451 - case TAG_GLOB_UNIT: 452 - strcpy(globtype, "UNIT"); 453 - break; 454 - 455 - case TAG_GLOB_REPORT_SZ: 456 - strcpy(globtype, "REPORT_SZ"); 457 - break; 458 - 459 - case TAG_GLOB_REPORT_ID: 460 - strcpy(globtype, "REPORT_ID"); 461 - /* New report, restart numbering */ 462 - inputnum = 0; 463 - break; 464 - 465 - case TAG_GLOB_REPORT_CNT: 466 - strcpy(globtype, "REPORT_CNT"); 467 - break; 468 - 469 - case TAG_GLOB_PUSH: 470 - strcpy(globtype, "PUSH"); 471 - break; 472 - 473 - case TAG_GLOB_POP: 474 - strcpy(globtype, "POP"); 475 - break; 476 - } 477 - 478 - /* Check to make sure we have a good tag number 479 - so we don't overflow array */ 480 - if (tag < TAG_GLOB_MAX) { 481 - switch (size) { 482 - case 1: 483 - dev_dbg(ddev, "%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x\n", 484 - indentstr, globtype, tag, size, data); 485 - globalval[tag] = data; 486 - break; 487 - 488 - case 2: 489 - dev_dbg(ddev, "%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x\n", 490 - indentstr, globtype, tag, size, data16); 491 - globalval[tag] = data16; 492 - break; 493 - 494 - case 4: 495 - dev_dbg(ddev, "%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x\n", 496 - indentstr, globtype, tag, size, data32); 497 - globalval[tag] = data32; 498 - break; 499 - } 500 - } else { 501 - dev_dbg(ddev, "%sGLOBALTAG: ILLEGAL TAG:%d SIZE: %d\n", 502 - indentstr, tag, size); 503 - } 504 - break; 505 - 506 - case TYPE_LOCAL: 507 - switch (tag) { 508 - case TAG_GLOB_USAGE: 509 - strcpy(globtype, "USAGE"); 510 - /* Always 1 byte */ 511 - usage = data; 512 - break; 513 - 514 - case TAG_GLOB_LOG_MIN: 515 - strcpy(globtype, "MIN"); 516 - break; 517 - 518 - case TAG_GLOB_LOG_MAX: 519 - strcpy(globtype, "MAX"); 520 - break; 521 - 522 - default: 523 - strcpy(globtype, "UNKNOWN"); 524 - break; 525 - } 526 - 527 - switch (size) { 528 - case 1: 529 - dev_dbg(ddev, "%sLOCALTAG:(%d) %s SIZE: %d Data: 0x%x\n", 530 - indentstr, tag, globtype, size, data); 531 - break; 532 - 533 - case 2: 534 - dev_dbg(ddev, "%sLOCALTAG:(%d) %s SIZE: %d Data: 0x%x\n", 535 - indentstr, tag, globtype, size, data16); 536 - break; 537 - 538 - case 4: 539 - dev_dbg(ddev, "%sLOCALTAG:(%d) %s SIZE: %d Data: 0x%x\n", 540 - indentstr, tag, globtype, size, data32); 541 - break; 542 - } 543 - 544 - break; 545 - } 546 - } 547 - } 548 - 549 - /* INPUT DRIVER Routines */ 550 - 551 - /* 552 - * Called when opening the input device. This will submit the URB to 553 - * the usb system so we start getting reports 554 - */ 555 - static int gtco_input_open(struct input_dev *inputdev) 556 - { 557 - struct gtco *device = input_get_drvdata(inputdev); 558 - 559 - device->urbinfo->dev = interface_to_usbdev(device->intf); 560 - if (usb_submit_urb(device->urbinfo, GFP_KERNEL)) 561 - return -EIO; 562 - 563 - return 0; 564 - } 565 - 566 - /* 567 - * Called when closing the input device. This will unlink the URB 568 - */ 569 - static void gtco_input_close(struct input_dev *inputdev) 570 - { 571 - struct gtco *device = input_get_drvdata(inputdev); 572 - 573 - usb_kill_urb(device->urbinfo); 574 - } 575 - 576 - 577 - /* 578 - * Setup input device capabilities. Tell the input system what this 579 - * device is capable of generating. 580 - * 581 - * This information is based on what is read from the HID report and 582 - * placed in the struct gtco structure 583 - * 584 - */ 585 - static void gtco_setup_caps(struct input_dev *inputdev) 586 - { 587 - struct gtco *device = input_get_drvdata(inputdev); 588 - 589 - /* Which events */ 590 - inputdev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) | 591 - BIT_MASK(EV_MSC); 592 - 593 - /* Misc event menu block */ 594 - inputdev->mscbit[0] = BIT_MASK(MSC_SCAN) | BIT_MASK(MSC_SERIAL) | 595 - BIT_MASK(MSC_RAW); 596 - 597 - /* Absolute values based on HID report info */ 598 - input_set_abs_params(inputdev, ABS_X, device->min_X, device->max_X, 599 - 0, 0); 600 - input_set_abs_params(inputdev, ABS_Y, device->min_Y, device->max_Y, 601 - 0, 0); 602 - 603 - /* Proximity */ 604 - input_set_abs_params(inputdev, ABS_DISTANCE, 0, 1, 0, 0); 605 - 606 - /* Tilt & pressure */ 607 - input_set_abs_params(inputdev, ABS_TILT_X, device->mintilt_X, 608 - device->maxtilt_X, 0, 0); 609 - input_set_abs_params(inputdev, ABS_TILT_Y, device->mintilt_Y, 610 - device->maxtilt_Y, 0, 0); 611 - input_set_abs_params(inputdev, ABS_PRESSURE, device->minpressure, 612 - device->maxpressure, 0, 0); 613 - 614 - /* Transducer */ 615 - input_set_abs_params(inputdev, ABS_MISC, 0, 0xFF, 0, 0); 616 - } 617 - 618 - /* USB Routines */ 619 - 620 - /* 621 - * URB callback routine. Called when we get IRQ reports from the 622 - * digitizer. 623 - * 624 - * This bridges the USB and input device worlds. It generates events 625 - * on the input device based on the USB reports. 626 - */ 627 - static void gtco_urb_callback(struct urb *urbinfo) 628 - { 629 - struct gtco *device = urbinfo->context; 630 - struct input_dev *inputdev; 631 - int rc; 632 - u32 val = 0; 633 - char le_buffer[2]; 634 - 635 - inputdev = device->inputdevice; 636 - 637 - /* Was callback OK? */ 638 - if (urbinfo->status == -ECONNRESET || 639 - urbinfo->status == -ENOENT || 640 - urbinfo->status == -ESHUTDOWN) { 641 - 642 - /* Shutdown is occurring. Return and don't queue up any more */ 643 - return; 644 - } 645 - 646 - if (urbinfo->status != 0) { 647 - /* 648 - * Some unknown error. Hopefully temporary. Just go and 649 - * requeue an URB 650 - */ 651 - goto resubmit; 652 - } 653 - 654 - /* 655 - * Good URB, now process 656 - */ 657 - 658 - /* PID dependent when we interpret the report */ 659 - if (inputdev->id.product == PID_1000 || 660 - inputdev->id.product == PID_1001 || 661 - inputdev->id.product == PID_1002) { 662 - 663 - /* 664 - * Switch on the report ID 665 - * Conveniently, the reports have more information, the higher 666 - * the report number. We can just fall through the case 667 - * statements if we start with the highest number report 668 - */ 669 - switch (device->buffer[0]) { 670 - case 5: 671 - /* Pressure is 9 bits */ 672 - val = ((u16)(device->buffer[8]) << 1); 673 - val |= (u16)(device->buffer[7] >> 7); 674 - input_report_abs(inputdev, ABS_PRESSURE, 675 - device->buffer[8]); 676 - 677 - /* Mask out the Y tilt value used for pressure */ 678 - device->buffer[7] = (u8)((device->buffer[7]) & 0x7F); 679 - fallthrough; 680 - 681 - case 4: 682 - /* Tilt */ 683 - input_report_abs(inputdev, ABS_TILT_X, 684 - sign_extend32(device->buffer[6], 6)); 685 - 686 - input_report_abs(inputdev, ABS_TILT_Y, 687 - sign_extend32(device->buffer[7], 6)); 688 - fallthrough; 689 - 690 - case 2: 691 - case 3: 692 - /* Convert buttons, only 5 bits possible */ 693 - val = (device->buffer[5]) & MASK_BUTTON; 694 - 695 - /* We don't apply any meaning to the bitmask, 696 - just report */ 697 - input_event(inputdev, EV_MSC, MSC_SERIAL, val); 698 - fallthrough; 699 - 700 - case 1: 701 - /* All reports have X and Y coords in the same place */ 702 - val = get_unaligned_le16(&device->buffer[1]); 703 - input_report_abs(inputdev, ABS_X, val); 704 - 705 - val = get_unaligned_le16(&device->buffer[3]); 706 - input_report_abs(inputdev, ABS_Y, val); 707 - 708 - /* Ditto for proximity bit */ 709 - val = device->buffer[5] & MASK_INRANGE ? 1 : 0; 710 - input_report_abs(inputdev, ABS_DISTANCE, val); 711 - 712 - /* Report 1 is an exception to how we handle buttons */ 713 - /* Buttons are an index, not a bitmask */ 714 - if (device->buffer[0] == 1) { 715 - 716 - /* 717 - * Convert buttons, 5 bit index 718 - * Report value of index set as one, 719 - * the rest as 0 720 - */ 721 - val = device->buffer[5] & MASK_BUTTON; 722 - dev_dbg(&device->intf->dev, 723 - "======>>>>>>REPORT 1: val 0x%X(%d)\n", 724 - val, val); 725 - 726 - /* 727 - * We don't apply any meaning to the button 728 - * index, just report it 729 - */ 730 - input_event(inputdev, EV_MSC, MSC_SERIAL, val); 731 - } 732 - break; 733 - 734 - case 7: 735 - /* Menu blocks */ 736 - input_event(inputdev, EV_MSC, MSC_SCAN, 737 - device->buffer[1]); 738 - break; 739 - } 740 - } 741 - 742 - /* Other pid class */ 743 - if (inputdev->id.product == PID_400 || 744 - inputdev->id.product == PID_401) { 745 - 746 - /* Report 2 */ 747 - if (device->buffer[0] == 2) { 748 - /* Menu blocks */ 749 - input_event(inputdev, EV_MSC, MSC_SCAN, device->buffer[1]); 750 - } 751 - 752 - /* Report 1 */ 753 - if (device->buffer[0] == 1) { 754 - char buttonbyte; 755 - 756 - /* IF X max > 64K, we still a bit from the y report */ 757 - if (device->max_X > 0x10000) { 758 - 759 - val = (u16)(((u16)(device->buffer[2] << 8)) | (u8)device->buffer[1]); 760 - val |= (u32)(((u8)device->buffer[3] & 0x1) << 16); 761 - 762 - input_report_abs(inputdev, ABS_X, val); 763 - 764 - le_buffer[0] = (u8)((u8)(device->buffer[3]) >> 1); 765 - le_buffer[0] |= (u8)((device->buffer[3] & 0x1) << 7); 766 - 767 - le_buffer[1] = (u8)(device->buffer[4] >> 1); 768 - le_buffer[1] |= (u8)((device->buffer[5] & 0x1) << 7); 769 - 770 - val = get_unaligned_le16(le_buffer); 771 - input_report_abs(inputdev, ABS_Y, val); 772 - 773 - /* 774 - * Shift the button byte right by one to 775 - * make it look like the standard report 776 - */ 777 - buttonbyte = device->buffer[5] >> 1; 778 - } else { 779 - 780 - val = get_unaligned_le16(&device->buffer[1]); 781 - input_report_abs(inputdev, ABS_X, val); 782 - 783 - val = get_unaligned_le16(&device->buffer[3]); 784 - input_report_abs(inputdev, ABS_Y, val); 785 - 786 - buttonbyte = device->buffer[5]; 787 - } 788 - 789 - /* BUTTONS and PROXIMITY */ 790 - val = buttonbyte & MASK_INRANGE ? 1 : 0; 791 - input_report_abs(inputdev, ABS_DISTANCE, val); 792 - 793 - /* Convert buttons, only 4 bits possible */ 794 - val = buttonbyte & 0x0F; 795 - #ifdef USE_BUTTONS 796 - for (i = 0; i < 5; i++) 797 - input_report_key(inputdev, BTN_DIGI + i, val & (1 << i)); 798 - #else 799 - /* We don't apply any meaning to the bitmask, just report */ 800 - input_event(inputdev, EV_MSC, MSC_SERIAL, val); 801 - #endif 802 - 803 - /* TRANSDUCER */ 804 - input_report_abs(inputdev, ABS_MISC, device->buffer[6]); 805 - } 806 - } 807 - 808 - /* Everybody gets report ID's */ 809 - input_event(inputdev, EV_MSC, MSC_RAW, device->buffer[0]); 810 - 811 - /* Sync it up */ 812 - input_sync(inputdev); 813 - 814 - resubmit: 815 - rc = usb_submit_urb(urbinfo, GFP_ATOMIC); 816 - if (rc != 0) 817 - dev_err(&device->intf->dev, 818 - "usb_submit_urb failed rc=0x%x\n", rc); 819 - } 820 - 821 - /* 822 - * The probe routine. This is called when the kernel find the matching USB 823 - * vendor/product. We do the following: 824 - * 825 - * - Allocate mem for a local structure to manage the device 826 - * - Request a HID Report Descriptor from the device and parse it to 827 - * find out the device parameters 828 - * - Create an input device and assign it attributes 829 - * - Allocate an URB so the device can talk to us when the input 830 - * queue is open 831 - */ 832 - static int gtco_probe(struct usb_interface *usbinterface, 833 - const struct usb_device_id *id) 834 - { 835 - 836 - struct gtco *gtco; 837 - struct input_dev *input_dev; 838 - struct hid_descriptor *hid_desc; 839 - char *report; 840 - int result = 0, retry; 841 - int error; 842 - struct usb_endpoint_descriptor *endpoint; 843 - struct usb_device *udev = interface_to_usbdev(usbinterface); 844 - 845 - /* Allocate memory for device structure */ 846 - gtco = kzalloc(sizeof(struct gtco), GFP_KERNEL); 847 - input_dev = input_allocate_device(); 848 - if (!gtco || !input_dev) { 849 - dev_err(&usbinterface->dev, "No more memory\n"); 850 - error = -ENOMEM; 851 - goto err_free_devs; 852 - } 853 - 854 - /* Set pointer to the input device */ 855 - gtco->inputdevice = input_dev; 856 - 857 - /* Save interface information */ 858 - gtco->intf = usbinterface; 859 - 860 - /* Allocate some data for incoming reports */ 861 - gtco->buffer = usb_alloc_coherent(udev, REPORT_MAX_SIZE, 862 - GFP_KERNEL, &gtco->buf_dma); 863 - if (!gtco->buffer) { 864 - dev_err(&usbinterface->dev, "No more memory for us buffers\n"); 865 - error = -ENOMEM; 866 - goto err_free_devs; 867 - } 868 - 869 - /* Allocate URB for reports */ 870 - gtco->urbinfo = usb_alloc_urb(0, GFP_KERNEL); 871 - if (!gtco->urbinfo) { 872 - dev_err(&usbinterface->dev, "Failed to allocate URB\n"); 873 - error = -ENOMEM; 874 - goto err_free_buf; 875 - } 876 - 877 - /* Sanity check that a device has an endpoint */ 878 - if (usbinterface->cur_altsetting->desc.bNumEndpoints < 1) { 879 - dev_err(&usbinterface->dev, 880 - "Invalid number of endpoints\n"); 881 - error = -EINVAL; 882 - goto err_free_urb; 883 - } 884 - 885 - endpoint = &usbinterface->cur_altsetting->endpoint[0].desc; 886 - 887 - /* Some debug */ 888 - dev_dbg(&usbinterface->dev, "gtco # interfaces: %d\n", usbinterface->num_altsetting); 889 - dev_dbg(&usbinterface->dev, "num endpoints: %d\n", usbinterface->cur_altsetting->desc.bNumEndpoints); 890 - dev_dbg(&usbinterface->dev, "interface class: %d\n", usbinterface->cur_altsetting->desc.bInterfaceClass); 891 - dev_dbg(&usbinterface->dev, "endpoint: attribute:0x%x type:0x%x\n", endpoint->bmAttributes, endpoint->bDescriptorType); 892 - if (usb_endpoint_xfer_int(endpoint)) 893 - dev_dbg(&usbinterface->dev, "endpoint: we have interrupt endpoint\n"); 894 - 895 - dev_dbg(&usbinterface->dev, "interface extra len:%d\n", 896 - usbinterface->cur_altsetting->extralen); 897 - 898 - /* 899 - * Find the HID descriptor so we can find out the size of the 900 - * HID report descriptor 901 - */ 902 - if (usb_get_extra_descriptor(usbinterface->cur_altsetting, 903 - HID_DEVICE_TYPE, &hid_desc) != 0) { 904 - dev_err(&usbinterface->dev, 905 - "Can't retrieve exta USB descriptor to get hid report descriptor length\n"); 906 - error = -EIO; 907 - goto err_free_urb; 908 - } 909 - 910 - dev_dbg(&usbinterface->dev, 911 - "Extra descriptor success: type:%d len:%d\n", 912 - hid_desc->bDescriptorType, hid_desc->wDescriptorLength); 913 - 914 - report = kzalloc(le16_to_cpu(hid_desc->wDescriptorLength), GFP_KERNEL); 915 - if (!report) { 916 - dev_err(&usbinterface->dev, "No more memory for report\n"); 917 - error = -ENOMEM; 918 - goto err_free_urb; 919 - } 920 - 921 - /* Couple of tries to get reply */ 922 - for (retry = 0; retry < 3; retry++) { 923 - result = usb_control_msg(udev, 924 - usb_rcvctrlpipe(udev, 0), 925 - USB_REQ_GET_DESCRIPTOR, 926 - USB_RECIP_INTERFACE | USB_DIR_IN, 927 - REPORT_DEVICE_TYPE << 8, 928 - 0, /* interface */ 929 - report, 930 - le16_to_cpu(hid_desc->wDescriptorLength), 931 - 5000); /* 5 secs */ 932 - 933 - dev_dbg(&usbinterface->dev, "usb_control_msg result: %d\n", result); 934 - if (result == le16_to_cpu(hid_desc->wDescriptorLength)) { 935 - parse_hid_report_descriptor(gtco, report, result); 936 - break; 937 - } 938 - } 939 - 940 - kfree(report); 941 - 942 - /* If we didn't get the report, fail */ 943 - if (result != le16_to_cpu(hid_desc->wDescriptorLength)) { 944 - dev_err(&usbinterface->dev, 945 - "Failed to get HID Report Descriptor of size: %d\n", 946 - hid_desc->wDescriptorLength); 947 - error = -EIO; 948 - goto err_free_urb; 949 - } 950 - 951 - /* Create a device file node */ 952 - usb_make_path(udev, gtco->usbpath, sizeof(gtco->usbpath)); 953 - strlcat(gtco->usbpath, "/input0", sizeof(gtco->usbpath)); 954 - 955 - /* Set Input device functions */ 956 - input_dev->open = gtco_input_open; 957 - input_dev->close = gtco_input_close; 958 - 959 - /* Set input device information */ 960 - input_dev->name = "GTCO_CalComp"; 961 - input_dev->phys = gtco->usbpath; 962 - 963 - input_set_drvdata(input_dev, gtco); 964 - 965 - /* Now set up all the input device capabilities */ 966 - gtco_setup_caps(input_dev); 967 - 968 - /* Set input device required ID information */ 969 - usb_to_input_id(udev, &input_dev->id); 970 - input_dev->dev.parent = &usbinterface->dev; 971 - 972 - /* Setup the URB, it will be posted later on open of input device */ 973 - usb_fill_int_urb(gtco->urbinfo, 974 - udev, 975 - usb_rcvintpipe(udev, 976 - endpoint->bEndpointAddress), 977 - gtco->buffer, 978 - REPORT_MAX_SIZE, 979 - gtco_urb_callback, 980 - gtco, 981 - endpoint->bInterval); 982 - 983 - gtco->urbinfo->transfer_dma = gtco->buf_dma; 984 - gtco->urbinfo->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 985 - 986 - /* Save gtco pointer in USB interface gtco */ 987 - usb_set_intfdata(usbinterface, gtco); 988 - 989 - /* All done, now register the input device */ 990 - error = input_register_device(input_dev); 991 - if (error) 992 - goto err_free_urb; 993 - 994 - return 0; 995 - 996 - err_free_urb: 997 - usb_free_urb(gtco->urbinfo); 998 - err_free_buf: 999 - usb_free_coherent(udev, REPORT_MAX_SIZE, 1000 - gtco->buffer, gtco->buf_dma); 1001 - err_free_devs: 1002 - input_free_device(input_dev); 1003 - kfree(gtco); 1004 - return error; 1005 - } 1006 - 1007 - /* 1008 - * This function is a standard USB function called when the USB device 1009 - * is disconnected. We will get rid of the URV, de-register the input 1010 - * device, and free up allocated memory 1011 - */ 1012 - static void gtco_disconnect(struct usb_interface *interface) 1013 - { 1014 - /* Grab private device ptr */ 1015 - struct gtco *gtco = usb_get_intfdata(interface); 1016 - struct usb_device *udev = interface_to_usbdev(interface); 1017 - 1018 - /* Now reverse all the registration stuff */ 1019 - if (gtco) { 1020 - input_unregister_device(gtco->inputdevice); 1021 - usb_kill_urb(gtco->urbinfo); 1022 - usb_free_urb(gtco->urbinfo); 1023 - usb_free_coherent(udev, REPORT_MAX_SIZE, 1024 - gtco->buffer, gtco->buf_dma); 1025 - kfree(gtco); 1026 - } 1027 - 1028 - dev_info(&interface->dev, "gtco driver disconnected\n"); 1029 - } 1030 - 1031 - /* STANDARD MODULE LOAD ROUTINES */ 1032 - 1033 - static struct usb_driver gtco_driverinfo_table = { 1034 - .name = "gtco", 1035 - .id_table = gtco_usbid_table, 1036 - .probe = gtco_probe, 1037 - .disconnect = gtco_disconnect, 1038 - }; 1039 - 1040 - module_usb_driver(gtco_driverinfo_table); 1041 - 1042 - MODULE_DESCRIPTION("GTCO digitizer USB driver"); 1043 - MODULE_LICENSE("GPL");
+4 -2
drivers/input/touchscreen/ad7877.c
··· 281 281 282 282 req->xfer[1].tx_buf = &req->ref_on; 283 283 req->xfer[1].len = 2; 284 - req->xfer[1].delay_usecs = ts->vref_delay_usecs; 284 + req->xfer[1].delay.value = ts->vref_delay_usecs; 285 + req->xfer[1].delay.unit = SPI_DELAY_UNIT_USECS; 285 286 req->xfer[1].cs_change = 1; 286 287 287 288 req->xfer[2].tx_buf = &req->command; 288 289 req->xfer[2].len = 2; 289 - req->xfer[2].delay_usecs = ts->vref_delay_usecs; 290 + req->xfer[2].delay.value = ts->vref_delay_usecs; 291 + req->xfer[2].delay.unit = SPI_DELAY_UNIT_USECS; 290 292 req->xfer[2].cs_change = 1; 291 293 292 294 req->xfer[3].rx_buf = &req->sample;
+3 -3
drivers/input/touchscreen/ad7879.c
··· 306 306 307 307 mutex_lock(&ts->input->mutex); 308 308 309 - if (!ts->suspended && !ts->disabled && ts->input->users) 309 + if (!ts->suspended && !ts->disabled && input_device_enabled(ts->input)) 310 310 __ad7879_disable(ts); 311 311 312 312 ts->suspended = true; ··· 322 322 323 323 mutex_lock(&ts->input->mutex); 324 324 325 - if (ts->suspended && !ts->disabled && ts->input->users) 325 + if (ts->suspended && !ts->disabled && input_device_enabled(ts->input)) 326 326 __ad7879_enable(ts); 327 327 328 328 ts->suspended = false; ··· 339 339 { 340 340 mutex_lock(&ts->input->mutex); 341 341 342 - if (!ts->suspended && ts->input->users != 0) { 342 + if (!ts->suspended && input_device_enabled(ts->input)) { 343 343 344 344 if (disable) { 345 345 if (ts->disabled)
+94 -153
drivers/input/touchscreen/ads7846.c
··· 32 32 #include <linux/spi/ads7846.h> 33 33 #include <linux/regulator/consumer.h> 34 34 #include <linux/module.h> 35 - #include <asm/irq.h> 35 + #include <asm/unaligned.h> 36 36 37 37 /* 38 38 * This code has been heavily tested on a Nokia 770, and lightly ··· 62 62 /* this driver doesn't aim at the peak continuous sample rate */ 63 63 #define SAMPLE_BITS (8 /*cmd*/ + 16 /*sample*/ + 2 /* before, after */) 64 64 65 - struct ts_event { 65 + struct ads7846_buf { 66 + u8 cmd; 66 67 /* 67 - * For portability, we can't read 12 bit values using SPI (which 68 - * would make the controller deliver them as native byte order u16 69 - * with msbs zeroed). Instead, we read them as two 8-bit values, 70 - * *** WHICH NEED BYTESWAPPING *** and range adjustment. 68 + * This union is a temporary hack. The driver does an in-place 69 + * endianness conversion. This will be cleaned up in the next 70 + * patch. 71 71 */ 72 - u16 x; 73 - u16 y; 74 - u16 z1, z2; 75 - bool ignore; 76 - u8 x_buf[3]; 77 - u8 y_buf[3]; 72 + union { 73 + __be16 data_be16; 74 + u16 data; 75 + }; 76 + } __packed; 77 + 78 + 79 + struct ts_event { 80 + bool ignore; 81 + struct ads7846_buf x; 82 + struct ads7846_buf y; 83 + struct ads7846_buf z1; 84 + struct ads7846_buf z2; 78 85 }; 79 86 80 87 /* ··· 90 83 * systems where main memory is not DMA-coherent (most non-x86 boards). 91 84 */ 92 85 struct ads7846_packet { 93 - u8 read_x, read_y, read_z1, read_z2, pwrdown; 94 - u16 dummy; /* for the pwrdown read */ 95 - struct ts_event tc; 96 - /* for ads7845 with mpc5121 psc spi we use 3-byte buffers */ 97 - u8 read_x_cmd[3], read_y_cmd[3], pwrdown_cmd[3]; 86 + struct ts_event tc; 87 + struct ads7846_buf read_x_cmd; 88 + struct ads7846_buf read_y_cmd; 89 + struct ads7846_buf read_z1_cmd; 90 + struct ads7846_buf read_z2_cmd; 91 + struct ads7846_buf pwrdown_cmd; 98 92 }; 99 93 100 94 struct ads7846 { ··· 207 199 #define REF_ON (READ_12BIT_DFR(x, 1, 1)) 208 200 #define REF_OFF (READ_12BIT_DFR(y, 0, 0)) 209 201 202 + static int get_pendown_state(struct ads7846 *ts) 203 + { 204 + if (ts->get_pendown_state) 205 + return ts->get_pendown_state(); 206 + 207 + return !gpio_get_value(ts->gpio_pendown); 208 + } 209 + 210 + static void ads7846_report_pen_up(struct ads7846 *ts) 211 + { 212 + struct input_dev *input = ts->input; 213 + 214 + input_report_key(input, BTN_TOUCH, 0); 215 + input_report_abs(input, ABS_PRESSURE, 0); 216 + input_sync(input); 217 + 218 + ts->pendown = false; 219 + dev_vdbg(&ts->spi->dev, "UP\n"); 220 + } 221 + 210 222 /* Must be called with ts->lock held */ 211 223 static void ads7846_stop(struct ads7846 *ts) 212 224 { ··· 243 215 static void ads7846_restart(struct ads7846 *ts) 244 216 { 245 217 if (!ts->disabled && !ts->suspended) { 218 + /* Check if pen was released since last stop */ 219 + if (ts->pendown && !get_pendown_state(ts)) 220 + ads7846_report_pen_up(ts); 221 + 246 222 /* Tell IRQ thread that it may poll the device. */ 247 223 ts->stopped = false; 248 224 mb(); ··· 443 411 444 412 if (status == 0) { 445 413 /* BE12 value, then padding */ 446 - status = be16_to_cpu(*((u16 *)&req->sample[1])); 414 + status = get_unaligned_be16(&req->sample[1]); 447 415 status = status >> 3; 448 416 status &= 0x0fff; 449 417 } ··· 513 481 static umode_t ads7846_is_visible(struct kobject *kobj, struct attribute *attr, 514 482 int index) 515 483 { 516 - struct device *dev = container_of(kobj, struct device, kobj); 484 + struct device *dev = kobj_to_dev(kobj); 517 485 struct ads7846 *ts = dev_get_drvdata(dev); 518 486 519 487 if (ts->model == 7843 && index < 2) /* in0, in1 */ ··· 638 606 639 607 /*--------------------------------------------------------------------------*/ 640 608 641 - static int get_pendown_state(struct ads7846 *ts) 642 - { 643 - if (ts->get_pendown_state) 644 - return ts->get_pendown_state(); 645 - 646 - return !gpio_get_value(ts->gpio_pendown); 647 - } 648 - 649 609 static void null_wait_for_sync(void) 650 610 { 651 611 } ··· 694 670 int value; 695 671 struct spi_transfer *t = 696 672 list_entry(m->transfers.prev, struct spi_transfer, transfer_list); 673 + struct ads7846_buf *buf = t->rx_buf; 697 674 698 - if (ts->model == 7845) { 699 - value = be16_to_cpup((__be16 *)&(((char *)t->rx_buf)[1])); 700 - } else { 701 - /* 702 - * adjust: on-wire is a must-ignore bit, a BE12 value, then 703 - * padding; built from two 8 bit values written msb-first. 704 - */ 705 - value = be16_to_cpup((__be16 *)t->rx_buf); 706 - } 675 + value = be16_to_cpup(&buf->data_be16); 707 676 708 677 /* enforce ADC output is 12 bits width */ 709 678 return (value >> 3) & 0xfff; ··· 706 689 { 707 690 struct spi_transfer *t = 708 691 list_entry(m->transfers.prev, struct spi_transfer, transfer_list); 692 + struct ads7846_buf *buf = t->rx_buf; 709 693 710 - *(u16 *)t->rx_buf = val; 694 + buf->data = val; 711 695 } 712 696 713 697 static void ads7846_read_state(struct ads7846 *ts) ··· 776 758 * from on-the-wire format as part of debouncing to get stable 777 759 * readings. 778 760 */ 761 + x = packet->tc.x.data; 762 + y = packet->tc.y.data; 779 763 if (ts->model == 7845) { 780 - x = *(u16 *)packet->tc.x_buf; 781 - y = *(u16 *)packet->tc.y_buf; 782 764 z1 = 0; 783 765 z2 = 0; 784 766 } else { 785 - x = packet->tc.x; 786 - y = packet->tc.y; 787 - z1 = packet->tc.z1; 788 - z2 = packet->tc.z2; 767 + z1 = packet->tc.z1.data; 768 + z2 = packet->tc.z2.data; 789 769 } 790 770 791 771 /* range filtering */ ··· 802 786 /* compute touch pressure resistance using equation #2 */ 803 787 Rt = z2; 804 788 Rt -= z1; 805 - Rt *= x; 806 789 Rt *= ts->x_plate_ohms; 790 + Rt = DIV_ROUND_CLOSEST(Rt, 16); 791 + Rt *= x; 807 792 Rt /= z1; 808 - Rt = (Rt + 2047) >> 12; 793 + Rt = DIV_ROUND_CLOSEST(Rt, 256); 809 794 } else { 810 795 Rt = 0; 811 796 } ··· 885 868 msecs_to_jiffies(TS_POLL_PERIOD)); 886 869 } 887 870 888 - if (ts->pendown && !ts->stopped) { 889 - struct input_dev *input = ts->input; 890 - 891 - input_report_key(input, BTN_TOUCH, 0); 892 - input_report_abs(input, ABS_PRESSURE, 0); 893 - input_sync(input); 894 - 895 - ts->pendown = false; 896 - dev_vdbg(&ts->spi->dev, "UP\n"); 897 - } 871 + if (ts->pendown && !ts->stopped) 872 + ads7846_report_pen_up(ts); 898 873 899 874 return IRQ_HANDLED; 900 875 } ··· 1001 992 spi_message_init(m); 1002 993 m->context = ts; 1003 994 1004 - if (ts->model == 7845) { 1005 - packet->read_y_cmd[0] = READ_Y(vref); 1006 - packet->read_y_cmd[1] = 0; 1007 - packet->read_y_cmd[2] = 0; 1008 - x->tx_buf = &packet->read_y_cmd[0]; 1009 - x->rx_buf = &packet->tc.y_buf[0]; 1010 - x->len = 3; 1011 - spi_message_add_tail(x, m); 1012 - } else { 1013 - /* y- still on; turn on only y+ (and ADC) */ 1014 - packet->read_y = READ_Y(vref); 1015 - x->tx_buf = &packet->read_y; 1016 - x->len = 1; 1017 - spi_message_add_tail(x, m); 1018 - 1019 - x++; 1020 - x->rx_buf = &packet->tc.y; 1021 - x->len = 2; 1022 - spi_message_add_tail(x, m); 1023 - } 995 + packet->read_y_cmd.cmd = READ_Y(vref); 996 + x->tx_buf = &packet->read_y_cmd; 997 + x->rx_buf = &packet->tc.y; 998 + x->len = 3; 999 + spi_message_add_tail(x, m); 1024 1000 1025 1001 /* 1026 1002 * The first sample after switching drivers can be low quality; ··· 1015 1021 if (pdata->settle_delay_usecs) { 1016 1022 x->delay.value = pdata->settle_delay_usecs; 1017 1023 x->delay.unit = SPI_DELAY_UNIT_USECS; 1018 - 1019 1024 x++; 1020 - x->tx_buf = &packet->read_y; 1021 - x->len = 1; 1022 - spi_message_add_tail(x, m); 1023 1025 1024 - x++; 1026 + x->tx_buf = &packet->read_y_cmd; 1025 1027 x->rx_buf = &packet->tc.y; 1026 - x->len = 2; 1028 + x->len = 3; 1027 1029 spi_message_add_tail(x, m); 1028 1030 } 1029 1031 ··· 1028 1038 spi_message_init(m); 1029 1039 m->context = ts; 1030 1040 1031 - if (ts->model == 7845) { 1032 - x++; 1033 - packet->read_x_cmd[0] = READ_X(vref); 1034 - packet->read_x_cmd[1] = 0; 1035 - packet->read_x_cmd[2] = 0; 1036 - x->tx_buf = &packet->read_x_cmd[0]; 1037 - x->rx_buf = &packet->tc.x_buf[0]; 1038 - x->len = 3; 1039 - spi_message_add_tail(x, m); 1040 - } else { 1041 - /* turn y- off, x+ on, then leave in lowpower */ 1042 - x++; 1043 - packet->read_x = READ_X(vref); 1044 - x->tx_buf = &packet->read_x; 1045 - x->len = 1; 1046 - spi_message_add_tail(x, m); 1047 - 1048 - x++; 1049 - x->rx_buf = &packet->tc.x; 1050 - x->len = 2; 1051 - spi_message_add_tail(x, m); 1052 - } 1041 + /* turn y- off, x+ on, then leave in lowpower */ 1042 + x++; 1043 + packet->read_x_cmd.cmd = READ_X(vref); 1044 + x->tx_buf = &packet->read_x_cmd; 1045 + x->rx_buf = &packet->tc.x; 1046 + x->len = 3; 1047 + spi_message_add_tail(x, m); 1053 1048 1054 1049 /* ... maybe discard first sample ... */ 1055 1050 if (pdata->settle_delay_usecs) { ··· 1042 1067 x->delay.unit = SPI_DELAY_UNIT_USECS; 1043 1068 1044 1069 x++; 1045 - x->tx_buf = &packet->read_x; 1046 - x->len = 1; 1047 - spi_message_add_tail(x, m); 1048 - 1049 - x++; 1070 + x->tx_buf = &packet->read_x_cmd; 1050 1071 x->rx_buf = &packet->tc.x; 1051 - x->len = 2; 1072 + x->len = 3; 1052 1073 spi_message_add_tail(x, m); 1053 1074 } 1054 1075 ··· 1056 1085 m->context = ts; 1057 1086 1058 1087 x++; 1059 - packet->read_z1 = READ_Z1(vref); 1060 - x->tx_buf = &packet->read_z1; 1061 - x->len = 1; 1062 - spi_message_add_tail(x, m); 1063 - 1064 - x++; 1088 + packet->read_z1_cmd.cmd = READ_Z1(vref); 1089 + x->tx_buf = &packet->read_z1_cmd; 1065 1090 x->rx_buf = &packet->tc.z1; 1066 - x->len = 2; 1091 + x->len = 3; 1067 1092 spi_message_add_tail(x, m); 1068 1093 1069 1094 /* ... maybe discard first sample ... */ ··· 1068 1101 x->delay.unit = SPI_DELAY_UNIT_USECS; 1069 1102 1070 1103 x++; 1071 - x->tx_buf = &packet->read_z1; 1072 - x->len = 1; 1073 - spi_message_add_tail(x, m); 1074 - 1075 - x++; 1104 + x->tx_buf = &packet->read_z1_cmd; 1076 1105 x->rx_buf = &packet->tc.z1; 1077 - x->len = 2; 1106 + x->len = 3; 1078 1107 spi_message_add_tail(x, m); 1079 1108 } 1080 1109 ··· 1080 1117 m->context = ts; 1081 1118 1082 1119 x++; 1083 - packet->read_z2 = READ_Z2(vref); 1084 - x->tx_buf = &packet->read_z2; 1085 - x->len = 1; 1086 - spi_message_add_tail(x, m); 1087 - 1088 - x++; 1120 + packet->read_z2_cmd.cmd = READ_Z2(vref); 1121 + x->tx_buf = &packet->read_z2_cmd; 1089 1122 x->rx_buf = &packet->tc.z2; 1090 - x->len = 2; 1123 + x->len = 3; 1091 1124 spi_message_add_tail(x, m); 1092 1125 1093 1126 /* ... maybe discard first sample ... */ ··· 1092 1133 x->delay.unit = SPI_DELAY_UNIT_USECS; 1093 1134 1094 1135 x++; 1095 - x->tx_buf = &packet->read_z2; 1096 - x->len = 1; 1097 - spi_message_add_tail(x, m); 1098 - 1099 - x++; 1136 + x->tx_buf = &packet->read_z2_cmd; 1100 1137 x->rx_buf = &packet->tc.z2; 1101 - x->len = 2; 1138 + x->len = 3; 1102 1139 spi_message_add_tail(x, m); 1103 1140 } 1104 1141 } ··· 1105 1150 spi_message_init(m); 1106 1151 m->context = ts; 1107 1152 1108 - if (ts->model == 7845) { 1109 - x++; 1110 - packet->pwrdown_cmd[0] = PWRDOWN; 1111 - packet->pwrdown_cmd[1] = 0; 1112 - packet->pwrdown_cmd[2] = 0; 1113 - x->tx_buf = &packet->pwrdown_cmd[0]; 1114 - x->len = 3; 1115 - } else { 1116 - x++; 1117 - packet->pwrdown = PWRDOWN; 1118 - x->tx_buf = &packet->pwrdown; 1119 - x->len = 1; 1120 - spi_message_add_tail(x, m); 1121 - 1122 - x++; 1123 - x->rx_buf = &packet->dummy; 1124 - x->len = 2; 1125 - } 1153 + x++; 1154 + packet->pwrdown_cmd.cmd = PWRDOWN; 1155 + x->tx_buf = &packet->pwrdown_cmd; 1156 + x->len = 3; 1126 1157 1127 1158 CS_CHANGE(*x); 1128 1159 spi_message_add_tail(x, m);
+43 -11
drivers/input/touchscreen/atmel_mxt_ts.c
··· 24 24 #include <linux/of.h> 25 25 #include <linux/property.h> 26 26 #include <linux/slab.h> 27 + #include <linux/regulator/consumer.h> 27 28 #include <linux/gpio/consumer.h> 28 29 #include <asm/unaligned.h> 29 30 #include <media/v4l2-device.h> ··· 310 309 u8 multitouch; 311 310 struct t7_config t7_cfg; 312 311 struct mxt_dbg dbg; 312 + struct regulator_bulk_data regulators[2]; 313 313 struct gpio_desc *reset_gpio; 314 314 bool use_retrigen_workaround; 315 315 ··· 608 606 609 607 static int mxt_send_bootloader_cmd(struct mxt_data *data, bool unlock) 610 608 { 611 - int ret; 612 609 u8 buf[2]; 613 610 614 611 if (unlock) { ··· 618 617 buf[1] = 0x01; 619 618 } 620 619 621 - ret = mxt_bootloader_write(data, buf, 2); 622 - if (ret) 623 - return ret; 624 - 625 - return 0; 620 + return mxt_bootloader_write(data, buf, sizeof(buf)); 626 621 } 627 622 628 623 static int __mxt_read_reg(struct i2c_client *client, ··· 3131 3134 if (error) 3132 3135 return error; 3133 3136 3137 + /* 3138 + * VDDA is the analog voltage supply 2.57..3.47 V 3139 + * VDD is the digital voltage supply 1.71..3.47 V 3140 + */ 3141 + data->regulators[0].supply = "vdda"; 3142 + data->regulators[1].supply = "vdd"; 3143 + error = devm_regulator_bulk_get(&client->dev, ARRAY_SIZE(data->regulators), 3144 + data->regulators); 3145 + if (error) { 3146 + if (error != -EPROBE_DEFER) 3147 + dev_err(&client->dev, "Failed to get regulators %d\n", 3148 + error); 3149 + return error; 3150 + } 3151 + 3152 + /* Request the RESET line as asserted so we go into reset */ 3134 3153 data->reset_gpio = devm_gpiod_get_optional(&client->dev, 3135 - "reset", GPIOD_OUT_LOW); 3154 + "reset", GPIOD_OUT_HIGH); 3136 3155 if (IS_ERR(data->reset_gpio)) { 3137 3156 error = PTR_ERR(data->reset_gpio); 3138 3157 dev_err(&client->dev, "Failed to get reset gpio: %d\n", error); ··· 3165 3152 3166 3153 disable_irq(client->irq); 3167 3154 3155 + error = regulator_bulk_enable(ARRAY_SIZE(data->regulators), 3156 + data->regulators); 3157 + if (error) { 3158 + dev_err(&client->dev, "failed to enable regulators: %d\n", 3159 + error); 3160 + return error; 3161 + } 3162 + /* 3163 + * The device takes 40ms to come up after power-on according 3164 + * to the mXT224 datasheet, page 13. 3165 + */ 3166 + msleep(MXT_BACKUP_TIME); 3167 + 3168 3168 if (data->reset_gpio) { 3169 + /* Wait a while and then de-assert the RESET GPIO line */ 3169 3170 msleep(MXT_RESET_GPIO_TIME); 3170 - gpiod_set_value(data->reset_gpio, 1); 3171 + gpiod_set_value(data->reset_gpio, 0); 3171 3172 msleep(MXT_RESET_INVALID_CHG); 3172 3173 } 3173 3174 3174 3175 error = mxt_initialize(data); 3175 3176 if (error) 3176 - return error; 3177 + goto err_disable_regulators; 3177 3178 3178 3179 error = sysfs_create_group(&client->dev.kobj, &mxt_attr_group); 3179 3180 if (error) { ··· 3201 3174 err_free_object: 3202 3175 mxt_free_input_device(data); 3203 3176 mxt_free_object_table(data); 3177 + err_disable_regulators: 3178 + regulator_bulk_disable(ARRAY_SIZE(data->regulators), 3179 + data->regulators); 3204 3180 return error; 3205 3181 } 3206 3182 ··· 3215 3185 sysfs_remove_group(&client->dev.kobj, &mxt_attr_group); 3216 3186 mxt_free_input_device(data); 3217 3187 mxt_free_object_table(data); 3188 + regulator_bulk_disable(ARRAY_SIZE(data->regulators), 3189 + data->regulators); 3218 3190 3219 3191 return 0; 3220 3192 } ··· 3232 3200 3233 3201 mutex_lock(&input_dev->mutex); 3234 3202 3235 - if (input_dev->users) 3203 + if (input_device_enabled(input_dev)) 3236 3204 mxt_stop(data); 3237 3205 3238 3206 mutex_unlock(&input_dev->mutex); ··· 3255 3223 3256 3224 mutex_lock(&input_dev->mutex); 3257 3225 3258 - if (input_dev->users) 3226 + if (input_device_enabled(input_dev)) 3259 3227 mxt_start(data); 3260 3228 3261 3229 mutex_unlock(&input_dev->mutex);
+4 -4
drivers/input/touchscreen/auo-pixcir-ts.c
··· 414 414 */ 415 415 if (device_may_wakeup(&client->dev)) { 416 416 /* need to start device if not open, to be wakeup source */ 417 - if (!input->users) { 417 + if (!input_device_enabled(input)) { 418 418 ret = auo_pixcir_start(ts); 419 419 if (ret) 420 420 goto unlock; ··· 422 422 423 423 enable_irq_wake(client->irq); 424 424 ret = auo_pixcir_power_mode(ts, AUO_PIXCIR_POWER_SLEEP); 425 - } else if (input->users) { 425 + } else if (input_device_enabled(input)) { 426 426 ret = auo_pixcir_stop(ts); 427 427 } 428 428 ··· 445 445 disable_irq_wake(client->irq); 446 446 447 447 /* need to stop device if it was not open on suspend */ 448 - if (!input->users) { 448 + if (!input_device_enabled(input)) { 449 449 ret = auo_pixcir_stop(ts); 450 450 if (ret) 451 451 goto unlock; 452 452 } 453 453 454 454 /* device wakes automatically from SLEEP */ 455 - } else if (input->users) { 455 + } else if (input_device_enabled(input)) { 456 456 ret = auo_pixcir_start(ts); 457 457 } 458 458
+2 -2
drivers/input/touchscreen/bu21029_ts.c
··· 430 430 431 431 if (!device_may_wakeup(dev)) { 432 432 mutex_lock(&bu21029->in_dev->mutex); 433 - if (bu21029->in_dev->users) 433 + if (input_device_enabled(bu21029->in_dev)) 434 434 bu21029_stop_chip(bu21029->in_dev); 435 435 mutex_unlock(&bu21029->in_dev->mutex); 436 436 } ··· 445 445 446 446 if (!device_may_wakeup(dev)) { 447 447 mutex_lock(&bu21029->in_dev->mutex); 448 - if (bu21029->in_dev->users) 448 + if (input_device_enabled(bu21029->in_dev)) 449 449 bu21029_start_chip(bu21029->in_dev); 450 450 mutex_unlock(&bu21029->in_dev->mutex); 451 451 }
+2 -2
drivers/input/touchscreen/chipone_icn8318.c
··· 154 154 struct icn8318_data *data = i2c_get_clientdata(to_i2c_client(dev)); 155 155 156 156 mutex_lock(&data->input->mutex); 157 - if (data->input->users) 157 + if (input_device_enabled(data->input)) 158 158 icn8318_stop(data->input); 159 159 mutex_unlock(&data->input->mutex); 160 160 ··· 166 166 struct icn8318_data *data = i2c_get_clientdata(to_i2c_client(dev)); 167 167 168 168 mutex_lock(&data->input->mutex); 169 - if (data->input->users) 169 + if (input_device_enabled(data->input)) 170 170 icn8318_start(data->input); 171 171 mutex_unlock(&data->input->mutex); 172 172
+14
drivers/input/touchscreen/cyttsp4_core.c
··· 30 30 31 31 #define CY_CORE_STARTUP_RETRY_COUNT 3 32 32 33 + static const char * const cyttsp4_tch_abs_string[] = { 34 + [CY_TCH_X] = "X", 35 + [CY_TCH_Y] = "Y", 36 + [CY_TCH_P] = "P", 37 + [CY_TCH_T] = "T", 38 + [CY_TCH_E] = "E", 39 + [CY_TCH_O] = "O", 40 + [CY_TCH_W] = "W", 41 + [CY_TCH_MAJ] = "MAJ", 42 + [CY_TCH_MIN] = "MIN", 43 + [CY_TCH_OR] = "OR", 44 + [CY_TCH_NUM_ABS] = "INVALID" 45 + }; 46 + 33 47 static const u8 ldr_exit[] = { 34 48 0xFF, 0x01, 0x3B, 0x00, 0x00, 0x4F, 0x6D, 0x17 35 49 };
-14
drivers/input/touchscreen/cyttsp4_core.h
··· 233 233 CY_TCH_NUM_ABS 234 234 }; 235 235 236 - static const char * const cyttsp4_tch_abs_string[] = { 237 - [CY_TCH_X] = "X", 238 - [CY_TCH_Y] = "Y", 239 - [CY_TCH_P] = "P", 240 - [CY_TCH_T] = "T", 241 - [CY_TCH_E] = "E", 242 - [CY_TCH_O] = "O", 243 - [CY_TCH_W] = "W", 244 - [CY_TCH_MAJ] = "MAJ", 245 - [CY_TCH_MIN] = "MIN", 246 - [CY_TCH_OR] = "OR", 247 - [CY_TCH_NUM_ABS] = "INVALID" 248 - }; 249 - 250 236 struct cyttsp4_touch { 251 237 int abs[CY_TCH_NUM_ABS]; 252 238 };
+2 -2
drivers/input/touchscreen/cyttsp_core.c
··· 479 479 480 480 mutex_lock(&ts->input->mutex); 481 481 482 - if (ts->input->users) { 482 + if (input_device_enabled(ts->input)) { 483 483 retval = cyttsp_disable(ts); 484 484 if (retval == 0) 485 485 ts->suspended = true; ··· 496 496 497 497 mutex_lock(&ts->input->mutex); 498 498 499 - if (ts->input->users) 499 + if (input_device_enabled(ts->input)) 500 500 cyttsp_enable(ts); 501 501 502 502 ts->suspended = false;
+17 -26
drivers/input/touchscreen/edt-ft5x06.c
··· 69 69 #define EDT_RAW_DATA_RETRIES 100 70 70 #define EDT_RAW_DATA_DELAY 1000 /* usec */ 71 71 72 + #define EDT_DEFAULT_NUM_X 1024 73 + #define EDT_DEFAULT_NUM_Y 1024 74 + 72 75 enum edt_pmode { 73 76 EDT_PMODE_NOT_SUPPORTED, 74 77 EDT_PMODE_HIBERNATE, ··· 980 977 } 981 978 } 982 979 983 - static void 984 - edt_ft5x06_ts_get_parameters(struct edt_ft5x06_ts_data *tsdata) 980 + static void edt_ft5x06_ts_get_parameters(struct edt_ft5x06_ts_data *tsdata) 985 981 { 986 982 struct edt_reg_addr *reg_addr = &tsdata->reg_addr; 987 983 ··· 999 997 if (reg_addr->reg_report_rate != NO_REGISTER) 1000 998 tsdata->report_rate = edt_ft5x06_register_read(tsdata, 1001 999 reg_addr->reg_report_rate); 1002 - if (tsdata->version == EDT_M06 || 1003 - tsdata->version == EDT_M09 || 1004 - tsdata->version == EDT_M12) { 1000 + tsdata->num_x = EDT_DEFAULT_NUM_X; 1001 + if (reg_addr->reg_num_x != NO_REGISTER) 1005 1002 tsdata->num_x = edt_ft5x06_register_read(tsdata, 1006 1003 reg_addr->reg_num_x); 1004 + tsdata->num_y = EDT_DEFAULT_NUM_Y; 1005 + if (reg_addr->reg_num_y != NO_REGISTER) 1007 1006 tsdata->num_y = edt_ft5x06_register_read(tsdata, 1008 1007 reg_addr->reg_num_y); 1009 - } else { 1010 - tsdata->num_x = -1; 1011 - tsdata->num_y = -1; 1012 - } 1013 1008 } 1014 1009 1015 - static void 1016 - edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata) 1010 + static void edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata) 1017 1011 { 1018 1012 struct edt_reg_addr *reg_addr = &tsdata->reg_addr; 1019 1013 ··· 1039 1041 1040 1042 case EV_FT: 1041 1043 reg_addr->reg_threshold = EV_REGISTER_THRESHOLD; 1044 + reg_addr->reg_report_rate = NO_REGISTER; 1042 1045 reg_addr->reg_gain = EV_REGISTER_GAIN; 1043 1046 reg_addr->reg_offset = NO_REGISTER; 1044 1047 reg_addr->reg_offset_x = EV_REGISTER_OFFSET_X; 1045 1048 reg_addr->reg_offset_y = EV_REGISTER_OFFSET_Y; 1046 1049 reg_addr->reg_num_x = NO_REGISTER; 1047 1050 reg_addr->reg_num_y = NO_REGISTER; 1048 - reg_addr->reg_report_rate = NO_REGISTER; 1049 1051 break; 1050 1052 1051 1053 case GENERIC_FT: 1052 1054 /* this is a guesswork */ 1053 1055 reg_addr->reg_threshold = M09_REGISTER_THRESHOLD; 1056 + reg_addr->reg_report_rate = NO_REGISTER; 1054 1057 reg_addr->reg_gain = M09_REGISTER_GAIN; 1055 1058 reg_addr->reg_offset = M09_REGISTER_OFFSET; 1056 1059 reg_addr->reg_offset_x = NO_REGISTER; 1057 1060 reg_addr->reg_offset_y = NO_REGISTER; 1061 + reg_addr->reg_num_x = NO_REGISTER; 1062 + reg_addr->reg_num_y = NO_REGISTER; 1058 1063 break; 1059 1064 } 1060 1065 } ··· 1196 1195 input->id.bustype = BUS_I2C; 1197 1196 input->dev.parent = &client->dev; 1198 1197 1199 - if (tsdata->version == EDT_M06 || 1200 - tsdata->version == EDT_M09 || 1201 - tsdata->version == EDT_M12) { 1202 - input_set_abs_params(input, ABS_MT_POSITION_X, 1203 - 0, tsdata->num_x * 64 - 1, 0, 0); 1204 - input_set_abs_params(input, ABS_MT_POSITION_Y, 1205 - 0, tsdata->num_y * 64 - 1, 0, 0); 1206 - } else { 1207 - /* Unknown maximum values. Specify via devicetree */ 1208 - input_set_abs_params(input, ABS_MT_POSITION_X, 1209 - 0, 65535, 0, 0); 1210 - input_set_abs_params(input, ABS_MT_POSITION_Y, 1211 - 0, 65535, 0, 0); 1212 - } 1198 + input_set_abs_params(input, ABS_MT_POSITION_X, 1199 + 0, tsdata->num_x * 64 - 1, 0, 0); 1200 + input_set_abs_params(input, ABS_MT_POSITION_Y, 1201 + 0, tsdata->num_y * 64 - 1, 0, 0); 1213 1202 1214 1203 touchscreen_parse_properties(input, true, &tsdata->prop); 1215 1204
+2 -2
drivers/input/touchscreen/eeti_ts.c
··· 241 241 242 242 mutex_lock(&input_dev->mutex); 243 243 244 - if (input_dev->users) 244 + if (input_device_enabled(input_dev)) 245 245 eeti_ts_stop(eeti); 246 246 247 247 mutex_unlock(&input_dev->mutex); ··· 263 263 264 264 mutex_lock(&input_dev->mutex); 265 265 266 - if (input_dev->users) 266 + if (input_device_enabled(input_dev)) 267 267 eeti_ts_start(eeti); 268 268 269 269 mutex_unlock(&input_dev->mutex);
+33 -3
drivers/input/touchscreen/ektf2127.c
··· 28 28 #define EKTF2127_RESPONSE 0x52 29 29 #define EKTF2127_REQUEST 0x53 30 30 #define EKTF2127_HELLO 0x55 31 + #define EKTF2127_REPORT2 0x5a 31 32 #define EKTF2127_REPORT 0x5d 32 33 #define EKTF2127_CALIB_DONE 0x66 33 34 ··· 96 95 input_sync(ts->input); 97 96 } 98 97 98 + static void ektf2127_report2_contact(struct ektf2127_ts *ts, int slot, 99 + const u8 *buf, bool active) 100 + { 101 + input_mt_slot(ts->input, slot); 102 + input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, active); 103 + 104 + if (active) { 105 + int x = (buf[0] & 0xf0) << 4 | buf[1]; 106 + int y = (buf[0] & 0x0f) << 8 | buf[2]; 107 + 108 + touchscreen_report_pos(ts->input, &ts->prop, x, y, true); 109 + } 110 + } 111 + 112 + static void ektf2127_report2_event(struct ektf2127_ts *ts, const u8 *buf) 113 + { 114 + ektf2127_report2_contact(ts, 0, &buf[1], !!(buf[7] & 2)); 115 + ektf2127_report2_contact(ts, 1, &buf[4], !!(buf[7] & 4)); 116 + 117 + input_mt_sync_frame(ts->input); 118 + input_sync(ts->input); 119 + } 120 + 99 121 static irqreturn_t ektf2127_irq(int irq, void *dev_id) 100 122 { 101 123 struct ektf2127_ts *ts = dev_id; ··· 135 111 switch (buf[0]) { 136 112 case EKTF2127_REPORT: 137 113 ektf2127_report_event(ts, buf); 114 + break; 115 + 116 + case EKTF2127_REPORT2: 117 + ektf2127_report2_event(ts, buf); 138 118 break; 139 119 140 120 case EKTF2127_NOISE: ··· 182 154 struct ektf2127_ts *ts = i2c_get_clientdata(to_i2c_client(dev)); 183 155 184 156 mutex_lock(&ts->input->mutex); 185 - if (ts->input->users) 157 + if (input_device_enabled(ts->input)) 186 158 ektf2127_stop(ts->input); 187 159 mutex_unlock(&ts->input->mutex); 188 160 ··· 194 166 struct ektf2127_ts *ts = i2c_get_clientdata(to_i2c_client(dev)); 195 167 196 168 mutex_lock(&ts->input->mutex); 197 - if (ts->input->users) 169 + if (input_device_enabled(ts->input)) 198 170 ektf2127_start(ts->input); 199 171 mutex_unlock(&ts->input->mutex); 200 172 ··· 333 305 #ifdef CONFIG_OF 334 306 static const struct of_device_id ektf2127_of_match[] = { 335 307 { .compatible = "elan,ektf2127" }, 308 + { .compatible = "elan,ektf2132" }, 336 309 {} 337 310 }; 338 311 MODULE_DEVICE_TABLE(of, ektf2127_of_match); ··· 341 312 342 313 static const struct i2c_device_id ektf2127_i2c_id[] = { 343 314 { "ektf2127", 0 }, 315 + { "ektf2132", 0 }, 344 316 {} 345 317 }; 346 318 MODULE_DEVICE_TABLE(i2c, ektf2127_i2c_id); ··· 357 327 }; 358 328 module_i2c_driver(ektf2127_driver); 359 329 360 - MODULE_DESCRIPTION("ELAN eKTF2127 I2C Touchscreen Driver"); 330 + MODULE_DESCRIPTION("ELAN eKTF2127/eKTF2132 I2C Touchscreen Driver"); 361 331 MODULE_AUTHOR("Michel Verlaan, Siebren Vroegindeweij"); 362 332 MODULE_LICENSE("GPL");
+13 -5
drivers/input/touchscreen/elants_i2c.c
··· 82 82 83 83 #define HEADER_REPORT_10_FINGER 0x62 84 84 85 - /* Header (4 bytes) plus 3 fill 10-finger packets */ 85 + /* Header (4 bytes) plus 3 full 10-finger packets */ 86 86 #define MAX_PACKET_SIZE 169 87 87 88 88 #define BOOT_TIME_DELAY_MS 50 ··· 96 96 #define E_INFO_OSR 0xD6 97 97 #define E_INFO_PHY_SCAN 0xD7 98 98 #define E_INFO_PHY_DRIVER 0xD8 99 + 100 + /* FW write command, 0x54 0x?? 0x0, 0x01 */ 101 + #define E_POWER_STATE_SLEEP 0x50 102 + #define E_POWER_STATE_RESUME 0x58 99 103 100 104 #define MAX_RETRIES 3 101 105 #define MAX_FW_UPDATE_RETRIES 30 ··· 273 269 { 274 270 struct i2c_client *client = ts->client; 275 271 int ret, error; 276 - static const u8 w_flashkey[] = { 0x54, 0xC0, 0xE1, 0x5A }; 277 - static const u8 rek[] = { 0x54, 0x29, 0x00, 0x01 }; 272 + static const u8 w_flashkey[] = { CMD_HEADER_WRITE, 0xC0, 0xE1, 0x5A }; 273 + static const u8 rek[] = { CMD_HEADER_WRITE, 0x29, 0x00, 0x01 }; 278 274 static const u8 rek_resp[] = { CMD_HEADER_REK, 0x66, 0x66, 0x66 }; 279 275 280 276 disable_irq(client->irq); ··· 1392 1388 { 1393 1389 struct i2c_client *client = to_i2c_client(dev); 1394 1390 struct elants_data *ts = i2c_get_clientdata(client); 1395 - const u8 set_sleep_cmd[] = { 0x54, 0x50, 0x00, 0x01 }; 1391 + const u8 set_sleep_cmd[] = { 1392 + CMD_HEADER_WRITE, E_POWER_STATE_SLEEP, 0x00, 0x01 1393 + }; 1396 1394 int retry_cnt; 1397 1395 int error; 1398 1396 ··· 1431 1425 { 1432 1426 struct i2c_client *client = to_i2c_client(dev); 1433 1427 struct elants_data *ts = i2c_get_clientdata(client); 1434 - const u8 set_active_cmd[] = { 0x54, 0x58, 0x00, 0x01 }; 1428 + const u8 set_active_cmd[] = { 1429 + CMD_HEADER_WRITE, E_POWER_STATE_RESUME, 0x00, 0x01 1430 + }; 1435 1431 int retry_cnt; 1436 1432 int error; 1437 1433
+4 -1
drivers/input/touchscreen/goodix.c
··· 576 576 * 577 577 * @ts: goodix_ts_data pointer 578 578 * @cfg: firmware config data 579 + * @len: config data length 579 580 */ 580 581 static int goodix_check_cfg(struct goodix_ts_data *ts, const u8 *cfg, int len) 581 582 { ··· 595 594 * 596 595 * @ts: goodix_ts_data pointer 597 596 * @cfg: config firmware to write to device 597 + * @len: config data length 598 598 */ 599 599 static int goodix_send_cfg(struct goodix_ts_data *ts, const u8 *cfg, int len) 600 600 { ··· 1170 1168 /** 1171 1169 * goodix_config_cb - Callback to finish device init 1172 1170 * 1173 - * @ts: our goodix_ts_data pointer 1171 + * @cfg: firmware config 1172 + * @ctx: our goodix_ts_data pointer 1174 1173 * 1175 1174 * request_firmware_wait callback that finishes 1176 1175 * initialization of the device.
+3 -4
drivers/input/touchscreen/imx6ul_tsc.c
··· 304 304 { 305 305 struct imx6ul_tsc *tsc = dev_id; 306 306 u32 coco; 307 - u32 value; 308 307 309 308 coco = readl(tsc->adc_regs + REG_ADC_HS); 310 309 if (coco & 0x01) { 311 - value = readl(tsc->adc_regs + REG_ADC_R0); 310 + readl(tsc->adc_regs + REG_ADC_R0); 312 311 complete(&tsc->completion); 313 312 } 314 313 ··· 520 521 521 522 mutex_lock(&input_dev->mutex); 522 523 523 - if (input_dev->users) 524 + if (input_device_enabled(input_dev)) 524 525 imx6ul_tsc_stop(tsc); 525 526 526 527 mutex_unlock(&input_dev->mutex); ··· 537 538 538 539 mutex_lock(&input_dev->mutex); 539 540 540 - if (input_dev->users) 541 + if (input_device_enabled(input_dev)) 541 542 retval = imx6ul_tsc_start(tsc); 542 543 543 544 mutex_unlock(&input_dev->mutex);
+1 -1
drivers/input/touchscreen/ipaq-micro-ts.c
··· 135 135 136 136 mutex_lock(&input->mutex); 137 137 138 - if (input->users) 138 + if (input_device_enabled(input)) 139 139 micro_ts_toggle_receive(ts, true); 140 140 141 141 mutex_unlock(&input->mutex);
+2 -2
drivers/input/touchscreen/iqs5xx.c
··· 1017 1017 1018 1018 mutex_lock(&input->mutex); 1019 1019 1020 - if (input->users) 1020 + if (input_device_enabled(input)) 1021 1021 error = iqs5xx_set_state(iqs5xx->client, IQS5XX_SUSPEND); 1022 1022 1023 1023 mutex_unlock(&input->mutex); ··· 1036 1036 1037 1037 mutex_lock(&input->mutex); 1038 1038 1039 - if (input->users) 1039 + if (input_device_enabled(input)) 1040 1040 error = iqs5xx_set_state(iqs5xx->client, IQS5XX_RESUME); 1041 1041 1042 1042 mutex_unlock(&input->mutex);
+2 -2
drivers/input/touchscreen/lpc32xx_ts.c
··· 334 334 */ 335 335 mutex_lock(&input->mutex); 336 336 337 - if (input->users) { 337 + if (input_device_enabled(input)) { 338 338 if (device_may_wakeup(dev)) 339 339 enable_irq_wake(tsc->irq); 340 340 else ··· 353 353 354 354 mutex_lock(&input->mutex); 355 355 356 - if (input->users) { 356 + if (input_device_enabled(input)) { 357 357 if (device_may_wakeup(dev)) 358 358 disable_irq_wake(tsc->irq); 359 359 else
+4 -4
drivers/input/touchscreen/melfas_mip4.c
··· 1256 1256 if (error) 1257 1257 return error; 1258 1258 1259 - if (ts->input->users) { 1259 + if (input_device_enabled(ts->input)) { 1260 1260 disable_irq(ts->client->irq); 1261 1261 } else { 1262 1262 error = mip4_power_on(ts); ··· 1276 1276 "Failed to flash firmware: %d\n", error); 1277 1277 1278 1278 /* Enable IRQ */ 1279 - if (ts->input->users) 1279 + if (input_device_enabled(ts->input)) 1280 1280 enable_irq(ts->client->irq); 1281 1281 else 1282 1282 mip4_power_off(ts); ··· 1539 1539 1540 1540 if (device_may_wakeup(dev)) 1541 1541 ts->wake_irq_enabled = enable_irq_wake(client->irq) == 0; 1542 - else if (input->users) 1542 + else if (input_device_enabled(input)) 1543 1543 mip4_disable(ts); 1544 1544 1545 1545 mutex_unlock(&input->mutex); ··· 1557 1557 1558 1558 if (ts->wake_irq_enabled) 1559 1559 disable_irq_wake(client->irq); 1560 - else if (input->users) 1560 + else if (input_device_enabled(input)) 1561 1561 mip4_enable(ts); 1562 1562 1563 1563 mutex_unlock(&input->mutex);
+3 -3
drivers/input/touchscreen/mms114.c
··· 199 199 int error; 200 200 201 201 mutex_lock(&input_dev->mutex); 202 - if (!input_dev->users) { 202 + if (!input_device_enabled(input_dev)) { 203 203 mutex_unlock(&input_dev->mutex); 204 204 goto out; 205 205 } ··· 564 564 input_sync(input_dev); 565 565 566 566 mutex_lock(&input_dev->mutex); 567 - if (input_dev->users) 567 + if (input_device_enabled(input_dev)) 568 568 mms114_stop(data); 569 569 mutex_unlock(&input_dev->mutex); 570 570 ··· 579 579 int error; 580 580 581 581 mutex_lock(&input_dev->mutex); 582 - if (input_dev->users) { 582 + if (input_device_enabled(input_dev)) { 583 583 error = mms114_start(data); 584 584 if (error < 0) { 585 585 mutex_unlock(&input_dev->mutex);
+4 -4
drivers/input/touchscreen/pixcir_i2c_ts.c
··· 415 415 mutex_lock(&input->mutex); 416 416 417 417 if (device_may_wakeup(&client->dev)) { 418 - if (!input->users) { 418 + if (!input_device_enabled(input)) { 419 419 ret = pixcir_start(ts); 420 420 if (ret) { 421 421 dev_err(dev, "Failed to start\n"); 422 422 goto unlock; 423 423 } 424 424 } 425 - } else if (input->users) { 425 + } else if (input_device_enabled(input)) { 426 426 ret = pixcir_stop(ts); 427 427 } 428 428 ··· 442 442 mutex_lock(&input->mutex); 443 443 444 444 if (device_may_wakeup(&client->dev)) { 445 - if (!input->users) { 445 + if (!input_device_enabled(input)) { 446 446 ret = pixcir_stop(ts); 447 447 if (ret) { 448 448 dev_err(dev, "Failed to stop\n"); 449 449 goto unlock; 450 450 } 451 451 } 452 - } else if (input->users) { 452 + } else if (input_device_enabled(input)) { 453 453 ret = pixcir_start(ts); 454 454 } 455 455
+1 -1
drivers/input/touchscreen/resistive-adc-touch.c
··· 23 23 #define GRTS_MAX_POS_MASK GENMASK(11, 0) 24 24 25 25 /** 26 - * grts_state - generic resistive touch screen information struct 26 + * struct grts_state - generic resistive touch screen information struct 27 27 * @pressure_min: number representing the minimum for the pressure 28 28 * @pressure: are we getting pressure info or not 29 29 * @iio_chans: list of channels acquired
+36 -16
drivers/input/touchscreen/st1232.c
··· 26 26 #define ST1232_TS_NAME "st1232-ts" 27 27 #define ST1633_TS_NAME "st1633-ts" 28 28 29 + #define REG_XY_RESOLUTION 0x04 30 + #define REG_XY_COORDINATES 0x12 29 31 #define ST_TS_MAX_FINGERS 10 30 32 31 33 struct st_chip_info { 32 34 bool have_z; 33 - u16 max_x; 34 - u16 max_y; 35 35 u16 max_area; 36 36 u16 max_fingers; 37 - u8 start_reg; 38 37 }; 39 38 40 39 struct st1232_ts_data { ··· 47 48 u8 *read_buf; 48 49 }; 49 50 50 - static int st1232_ts_read_data(struct st1232_ts_data *ts) 51 + static int st1232_ts_read_data(struct st1232_ts_data *ts, u8 reg) 51 52 { 52 53 struct i2c_client *client = ts->client; 53 - u8 start_reg = ts->chip_info->start_reg; 54 54 struct i2c_msg msg[] = { 55 55 { 56 56 .addr = client->addr, 57 - .len = sizeof(start_reg), 58 - .buf = &start_reg, 57 + .len = sizeof(reg), 58 + .buf = &reg, 59 59 }, 60 60 { 61 61 .addr = client->addr, ··· 68 70 ret = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg)); 69 71 if (ret != ARRAY_SIZE(msg)) 70 72 return ret < 0 ? ret : -EIO; 73 + 74 + return 0; 75 + } 76 + 77 + static int st1232_ts_read_resolution(struct st1232_ts_data *ts, u16 *max_x, 78 + u16 *max_y) 79 + { 80 + u8 *buf; 81 + int error; 82 + 83 + /* select resolution register */ 84 + error = st1232_ts_read_data(ts, REG_XY_RESOLUTION); 85 + if (error) 86 + return error; 87 + 88 + buf = ts->read_buf; 89 + 90 + *max_x = ((buf[0] & 0x0070) << 4) | buf[1]; 91 + *max_y = ((buf[0] & 0x0007) << 8) | buf[2]; 71 92 72 93 return 0; 73 94 } ··· 140 123 int count; 141 124 int error; 142 125 143 - error = st1232_ts_read_data(ts); 126 + error = st1232_ts_read_data(ts, REG_XY_COORDINATES); 144 127 if (error) 145 128 goto out; 146 129 ··· 174 157 175 158 static const struct st_chip_info st1232_chip_info = { 176 159 .have_z = true, 177 - .max_x = 0x31f, /* 800 - 1 */ 178 - .max_y = 0x1df, /* 480 -1 */ 179 160 .max_area = 0xff, 180 161 .max_fingers = 2, 181 - .start_reg = 0x12, 182 162 }; 183 163 184 164 static const struct st_chip_info st1633_chip_info = { 185 165 .have_z = false, 186 - .max_x = 0x13f, /* 320 - 1 */ 187 - .max_y = 0x1df, /* 480 -1 */ 188 166 .max_area = 0x00, 189 167 .max_fingers = 5, 190 - .start_reg = 0x12, 191 168 }; 192 169 193 170 static int st1232_ts_probe(struct i2c_client *client, ··· 190 179 const struct st_chip_info *match; 191 180 struct st1232_ts_data *ts; 192 181 struct input_dev *input_dev; 182 + u16 max_x, max_y; 193 183 int error; 194 184 195 185 match = device_get_match_data(&client->dev); ··· 251 239 input_dev->name = "st1232-touchscreen"; 252 240 input_dev->id.bustype = BUS_I2C; 253 241 242 + /* Read resolution from the chip */ 243 + error = st1232_ts_read_resolution(ts, &max_x, &max_y); 244 + if (error) { 245 + dev_err(&client->dev, 246 + "Failed to read resolution: %d\n", error); 247 + return error; 248 + } 249 + 254 250 if (ts->chip_info->have_z) 255 251 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 256 252 ts->chip_info->max_area, 0, 0); 257 253 258 254 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 259 - 0, ts->chip_info->max_x, 0, 0); 255 + 0, max_x, 0, 0); 260 256 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 261 - 0, ts->chip_info->max_y, 0, 0); 257 + 0, max_y, 0, 0); 262 258 263 259 touchscreen_parse_properties(input_dev, true, &ts->prop); 264 260
+5 -2
drivers/input/touchscreen/stmpe-ts.c
··· 14 14 #include <linux/of.h> 15 15 #include <linux/platform_device.h> 16 16 #include <linux/input.h> 17 + #include <linux/input/touchscreen.h> 17 18 #include <linux/slab.h> 18 19 #include <linux/delay.h> 19 20 #include <linux/i2c.h> ··· 73 72 struct input_dev *idev; 74 73 struct delayed_work work; 75 74 struct device *dev; 75 + struct touchscreen_properties prop; 76 76 u8 ave_ctrl; 77 77 u8 touch_det_delay; 78 78 u8 settling; ··· 152 150 y = ((data_set[1] & 0xf) << 8) | data_set[2]; 153 151 z = data_set[3]; 154 152 155 - input_report_abs(ts->idev, ABS_X, x); 156 - input_report_abs(ts->idev, ABS_Y, y); 153 + touchscreen_report_pos(ts->idev, &ts->prop, x, y, false); 157 154 input_report_abs(ts->idev, ABS_PRESSURE, z); 158 155 input_report_key(ts->idev, BTN_TOUCH, 1); 159 156 input_sync(ts->idev); ··· 337 336 input_set_abs_params(idev, ABS_X, 0, XY_MASK, 0, 0); 338 337 input_set_abs_params(idev, ABS_Y, 0, XY_MASK, 0, 0); 339 338 input_set_abs_params(idev, ABS_PRESSURE, 0x0, 0xff, 0, 0); 339 + 340 + touchscreen_parse_properties(idev, false, &ts->prop); 340 341 341 342 error = input_register_device(idev); 342 343 if (error) {
+1 -1
drivers/input/touchscreen/surface3_spi.c
··· 219 219 /** 220 220 * surface3_spi_get_gpio_config - Get GPIO config from ACPI/DT 221 221 * 222 - * @ts: surface3_spi_ts_data pointer 222 + * @data: surface3_spi_ts_data pointer 223 223 */ 224 224 static int surface3_spi_get_gpio_config(struct surface3_ts_data *data) 225 225 {
+2 -2
drivers/input/touchscreen/ucb1400_ts.c
··· 410 410 411 411 mutex_lock(&idev->mutex); 412 412 413 - if (idev->users) 413 + if (input_device_enabled(idev)) 414 414 ucb1400_ts_stop(ucb); 415 415 416 416 mutex_unlock(&idev->mutex); ··· 424 424 425 425 mutex_lock(&idev->mutex); 426 426 427 - if (idev->users) 427 + if (input_device_enabled(idev)) 428 428 ucb1400_ts_start(ucb); 429 429 430 430 mutex_unlock(&idev->mutex);
+10 -6
drivers/input/touchscreen/wm97xx-core.c
··· 194 194 * wm97xx_set_gpio - Set the status of a codec GPIO. 195 195 * @wm: wm97xx device. 196 196 * @gpio: gpio 197 - * 197 + * @status: status 198 198 * 199 199 * Set the status of a codec GPIO pin 200 200 */ ··· 806 806 else 807 807 suspend_mode = 0; 808 808 809 - if (wm->input_dev->users) 809 + mutex_lock(&wm->input_dev->mutex); 810 + if (input_device_enabled(wm->input_dev)) 810 811 cancel_delayed_work_sync(&wm->ts_reader); 811 812 812 813 /* Power down the digitiser (bypassing the cache for resume) */ 813 814 reg = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER2); 814 815 reg &= ~WM97XX_PRP_DET_DIG; 815 - if (wm->input_dev->users) 816 + if (input_device_enabled(wm->input_dev)) 816 817 reg |= suspend_mode; 817 818 wm->ac97->bus->ops->write(wm->ac97, AC97_WM97XX_DIGITISER2, reg); 818 819 819 820 /* WM9713 has an additional power bit - turn it off if there 820 821 * are no users or if suspend mode is zero. */ 821 822 if (wm->id == WM9713_ID2 && 822 - (!wm->input_dev->users || !suspend_mode)) { 823 + (!input_device_enabled(wm->input_dev) || !suspend_mode)) { 823 824 reg = wm97xx_reg_read(wm, AC97_EXTENDED_MID) | 0x8000; 824 825 wm97xx_reg_write(wm, AC97_EXTENDED_MID, reg); 825 826 } 827 + mutex_unlock(&wm->input_dev->mutex); 826 828 827 829 return 0; 828 830 } ··· 833 831 { 834 832 struct wm97xx *wm = dev_get_drvdata(dev); 835 833 834 + mutex_lock(&wm->input_dev->mutex); 836 835 /* restore digitiser and gpios */ 837 836 if (wm->id == WM9713_ID2) { 838 837 wm97xx_reg_write(wm, AC97_WM9713_DIG1, wm->dig[0]); 839 838 wm97xx_reg_write(wm, 0x5a, wm->misc); 840 - if (wm->input_dev->users) { 839 + if (input_device_enabled(wm->input_dev)) { 841 840 u16 reg; 842 841 reg = wm97xx_reg_read(wm, AC97_EXTENDED_MID) & 0x7fff; 843 842 wm97xx_reg_write(wm, AC97_EXTENDED_MID, reg); ··· 855 852 wm97xx_reg_write(wm, AC97_GPIO_STATUS, wm->gpio[4]); 856 853 wm97xx_reg_write(wm, AC97_MISC_AFE, wm->gpio[5]); 857 854 858 - if (wm->input_dev->users && !wm->pen_irq) { 855 + if (input_device_enabled(wm->input_dev) && !wm->pen_irq) { 859 856 wm->ts_reader_interval = wm->ts_reader_min_interval; 860 857 queue_delayed_work(wm->ts_workq, &wm->ts_reader, 861 858 wm->ts_reader_interval); 862 859 } 860 + mutex_unlock(&wm->input_dev->mutex); 863 861 864 862 return 0; 865 863 }
+4 -4
drivers/input/touchscreen/zforce_ts.c
··· 626 626 dev_dbg(&client->dev, "suspend while being a wakeup source\n"); 627 627 628 628 /* Need to start device, if not open, to be a wakeup source. */ 629 - if (!input->users) { 629 + if (!input_device_enabled(input)) { 630 630 ret = zforce_start(ts); 631 631 if (ret) 632 632 goto unlock; 633 633 } 634 634 635 635 enable_irq_wake(client->irq); 636 - } else if (input->users) { 636 + } else if (input_device_enabled(input)) { 637 637 dev_dbg(&client->dev, 638 638 "suspend without being a wakeup source\n"); 639 639 ··· 670 670 disable_irq_wake(client->irq); 671 671 672 672 /* need to stop device if it was not open on suspend */ 673 - if (!input->users) { 673 + if (!input_device_enabled(input)) { 674 674 ret = zforce_stop(ts); 675 675 if (ret) 676 676 goto unlock; 677 677 } 678 - } else if (input->users) { 678 + } else if (input_device_enabled(input)) { 679 679 dev_dbg(&client->dev, "resume without being a wakeup source\n"); 680 680 681 681 enable_irq(client->irq);
+2 -2
drivers/input/touchscreen/zinitix.c
··· 532 532 533 533 mutex_lock(&bt541->input_dev->mutex); 534 534 535 - if (bt541->input_dev->users) 535 + if (input_device_enabled(bt541->input_dev)) 536 536 zinitix_stop(bt541); 537 537 538 538 mutex_unlock(&bt541->input_dev->mutex); ··· 548 548 549 549 mutex_lock(&bt541->input_dev->mutex); 550 550 551 - if (bt541->input_dev->users) 551 + if (input_device_enabled(bt541->input_dev)) 552 552 ret = zinitix_start(bt541); 553 553 554 554 mutex_unlock(&bt541->input_dev->mutex);
-58
include/linux/input-polldev.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-only */ 2 - #ifndef _INPUT_POLLDEV_H 3 - #define _INPUT_POLLDEV_H 4 - 5 - /* 6 - * Copyright (c) 2007 Dmitry Torokhov 7 - */ 8 - 9 - #include <linux/input.h> 10 - #include <linux/workqueue.h> 11 - 12 - /** 13 - * struct input_polled_dev - simple polled input device 14 - * @private: private driver data. 15 - * @open: driver-supplied method that prepares device for polling 16 - * (enabled the device and maybe flushes device state). 17 - * @close: driver-supplied method that is called when device is no 18 - * longer being polled. Used to put device into low power mode. 19 - * @poll: driver-supplied method that polls the device and posts 20 - * input events (mandatory). 21 - * @poll_interval: specifies how often the poll() method should be called. 22 - * Defaults to 500 msec unless overridden when registering the device. 23 - * @poll_interval_max: specifies upper bound for the poll interval. 24 - * Defaults to the initial value of @poll_interval. 25 - * @poll_interval_min: specifies lower bound for the poll interval. 26 - * Defaults to 0. 27 - * @input: input device structure associated with the polled device. 28 - * Must be properly initialized by the driver (id, name, phys, bits). 29 - * 30 - * Polled input device provides a skeleton for supporting simple input 31 - * devices that do not raise interrupts but have to be periodically 32 - * scanned or polled to detect changes in their state. 33 - */ 34 - struct input_polled_dev { 35 - void *private; 36 - 37 - void (*open)(struct input_polled_dev *dev); 38 - void (*close)(struct input_polled_dev *dev); 39 - void (*poll)(struct input_polled_dev *dev); 40 - unsigned int poll_interval; /* msec */ 41 - unsigned int poll_interval_max; /* msec */ 42 - unsigned int poll_interval_min; /* msec */ 43 - 44 - struct input_dev *input; 45 - 46 - /* private: */ 47 - struct delayed_work work; 48 - 49 - bool devres_managed; 50 - }; 51 - 52 - struct input_polled_dev *input_allocate_polled_device(void); 53 - struct input_polled_dev *devm_input_allocate_polled_device(struct device *dev); 54 - void input_free_polled_device(struct input_polled_dev *dev); 55 - int input_register_polled_device(struct input_polled_dev *dev); 56 - void input_unregister_polled_device(struct input_polled_dev *dev); 57 - 58 - #endif
+12 -2
include/linux/input.h
··· 90 90 * @open: this method is called when the very first user calls 91 91 * input_open_device(). The driver must prepare the device 92 92 * to start generating events (start polling thread, 93 - * request an IRQ, submit URB, etc.) 93 + * request an IRQ, submit URB, etc.). The meaning of open() is 94 + * to start providing events to the input core. 94 95 * @close: this method is called when the very last user calls 95 - * input_close_device(). 96 + * input_close_device(). The meaning of close() is to stop 97 + * providing events to the input core. 96 98 * @flush: purges the device. Most commonly used to get rid of force 97 99 * feedback effects loaded into the device when disconnecting 98 100 * from it ··· 129 127 * and needs not be explicitly unregistered or freed. 130 128 * @timestamp: storage for a timestamp set by input_set_timestamp called 131 129 * by a driver 130 + * @inhibited: indicates that the input device is inhibited. If that is 131 + * the case then input core ignores any events generated by the device. 132 + * Device's close() is called when it is being inhibited and its open() 133 + * is called when it is being uninhibited. 132 134 */ 133 135 struct input_dev { 134 136 const char *name; ··· 207 201 bool devres_managed; 208 202 209 203 ktime_t timestamp[INPUT_CLK_MAX]; 204 + 205 + bool inhibited; 210 206 }; 211 207 #define to_input_dev(d) container_of(d, struct input_dev, dev) 212 208 ··· 509 501 const struct input_device_id *id); 510 502 511 503 void input_enable_softrepeat(struct input_dev *dev, int delay, int period); 504 + 505 + bool input_device_enabled(struct input_dev *dev); 512 506 513 507 extern struct class input_class; 514 508
-7
include/linux/input/adp5589.h
··· 175 175 176 176 struct adp5589_gpio_platform_data { 177 177 int gpio_start; /* GPIO Chip base # */ 178 - int (*setup)(struct i2c_client *client, 179 - int gpio, unsigned ngpio, 180 - void *context); 181 - int (*teardown)(struct i2c_client *client, 182 - int gpio, unsigned ngpio, 183 - void *context); 184 - void *context; 185 178 }; 186 179 187 180 #endif
-1
kernel/configs/android-recommended.config
··· 111 111 CONFIG_SUSPEND_TIME=y 112 112 CONFIG_TABLET_USB_ACECAD=y 113 113 CONFIG_TABLET_USB_AIPTEK=y 114 - CONFIG_TABLET_USB_GTCO=y 115 114 CONFIG_TABLET_USB_HANWANG=y 116 115 CONFIG_TABLET_USB_KBTAB=y 117 116 CONFIG_TASKSTATS=y