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

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

Pull input updates from Dmitry Torokhov:

- a new driver for IBM Operational Panel

- a new driver for PinePhone keyboards

- RT5120 PMIC power key support

- various enhancements and support for new models in xpad (Xbox) driver

- a new compatible ID for Elan touchscreen driver

- rework of adp5588-keys driver to support configuring via device
properties (OF, ACPI, etc) instead of platform data, and proper
support of optional gpiochip functionality (and removal of
gpio-adp5588 driver)

- improvements to firmware update handling in Synaptics RMI4 driver

- support for double key matrix in mt6779-keypad

- support for polled mode in adc-joystick driver

- other assorted driver fixes, cleanups and improvements

* tag 'input-for-v6.1-rc0' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (90 commits)
Input: i8042 - fix refount leak on sparc
Input: i8042 - add LoongArch support in i8042-acpipnpio.h
Input: i8042 - rename i8042-x86ia64io.h to i8042-acpipnpio.h
Input: pinephone-keyboard - support the proxied I2C bus
Input: pinephone-keyboard - add PinePhone keyboard driver
dt-bindings: input: Add the PinePhone keyboard binding
dt-bindings: input: Convert hid-over-i2c to DT schema
input: drop empty comment blocks
Input: xpad - add X-Box Adaptive Profile button
Input: add ABS_PROFILE to uapi and documentation
Input: xpad - add X-Box Adaptive XBox button
Input: xpad - add X-Box Adaptive support
Input: ims-pcu - fix spelling mistake "BOOLTLOADER" -> "BOOTLOADER"
Input: ibm-panel - add missing MODULE_DEVICE_TABLE
Input: icn8505 - utilize acpi_get_subsystem_id()
Input: xpad - decipher xpadone packages with GIP defines
Input: xpad - refactor using BIT() macro
Input: synaptics-rmi4 - convert to use sysfs_emit() APIs
Input: twl4030-pwrbutton - add missing of.h include
Input: applespi - replace zero-length array with DECLARE_FLEX_ARRAY() helper
...

+2657 -1950
+5
Documentation/devicetree/bindings/input/adc-joystick.yaml
··· 14 14 Bindings for joystick devices connected to ADC controllers supporting 15 15 the Industrial I/O subsystem. 16 16 17 + allOf: 18 + - $ref: input.yaml# 19 + 17 20 properties: 18 21 compatible: 19 22 const: adc-joystick ··· 30 27 See 31 28 https://github.com/devicetree-org/dt-schema/blob/master/schemas/iio/iio-consumer.yaml 32 29 for details. 30 + 31 + poll-interval: true 33 32 34 33 '#address-cells': 35 34 const: 1
+111
Documentation/devicetree/bindings/input/adi,adp5588.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/adi,adp5588.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Analog Devices ADP5588 Keypad Controller 8 + 9 + maintainers: 10 + - Nuno Sá <nuno.sa@analog.com> 11 + 12 + description: | 13 + Analog Devices Mobile I/O Expander and QWERTY Keypad Controller 14 + https://www.analog.com/media/en/technical-documentation/data-sheets/ADP5588.pdf 15 + 16 + allOf: 17 + - $ref: matrix-keymap.yaml# 18 + - $ref: input.yaml# 19 + 20 + properties: 21 + compatible: 22 + enum: 23 + - adi,adp5587 24 + - adi,adp5588 25 + 26 + reg: 27 + maxItems: 1 28 + 29 + vcc-supply: 30 + description: Supply Voltage Input 31 + 32 + reset-gpios: 33 + description: 34 + If specified, it will be asserted during driver probe. As the line is 35 + active low, it should be marked GPIO_ACTIVE_LOW. 36 + maxItems: 1 37 + 38 + interrupts: 39 + maxItems: 1 40 + 41 + gpio-controller: 42 + description: 43 + This property applies if either keypad,num-rows lower than 8 or 44 + keypad,num-columns lower than 10. 45 + 46 + '#gpio-cells': 47 + const: 2 48 + 49 + interrupt-controller: 50 + description: 51 + This property applies if either keypad,num-rows lower than 8 or 52 + keypad,num-columns lower than 10. 53 + 54 + '#interrupt-cells': 55 + const: 2 56 + 57 + adi,unlock-keys: 58 + description: 59 + Specifies a maximum of 2 keys that can be used to unlock the keypad. 60 + If this property is set, the keyboard will be locked and only unlocked 61 + after these keys are pressed. If only one key is set, a double click is 62 + needed to unlock the keypad. The value of this property cannot be bigger 63 + or equal than keypad,num-rows * keypad,num-columns. 64 + $ref: /schemas/types.yaml#/definitions/uint32-array 65 + minItems: 1 66 + maxItems: 2 67 + 68 + required: 69 + - compatible 70 + - reg 71 + - interrupts 72 + - keypad,num-rows 73 + - keypad,num-columns 74 + - linux,keymap 75 + 76 + unevaluatedProperties: false 77 + 78 + examples: 79 + - | 80 + #include <dt-bindings/interrupt-controller/irq.h> 81 + #include <dt-bindings/input/input.h> 82 + #include <dt-bindings/gpio/gpio.h> 83 + i2c { 84 + #address-cells = <1>; 85 + #size-cells = <0>; 86 + 87 + keys@34 { 88 + compatible = "adi,adp5588"; 89 + reg = <0x34>; 90 + 91 + vcc-supply = <&vcc>; 92 + interrupts = <21 IRQ_TYPE_EDGE_FALLING>; 93 + interrupt-parent = <&gpio>; 94 + reset-gpios = <&gpio 20 GPIO_ACTIVE_LOW>; 95 + 96 + keypad,num-rows = <1>; 97 + keypad,num-columns = <9>; 98 + linux,keymap = < 99 + MATRIX_KEY(0x00, 0x00, KEY_1) 100 + MATRIX_KEY(0x00, 0x01, KEY_2) 101 + MATRIX_KEY(0x00, 0x02, KEY_3) 102 + MATRIX_KEY(0x00, 0x03, KEY_4) 103 + MATRIX_KEY(0x00, 0x04, KEY_5) 104 + MATRIX_KEY(0x00, 0x05, KEY_6) 105 + MATRIX_KEY(0x00, 0x06, KEY_7) 106 + MATRIX_KEY(0x00, 0x07, KEY_8) 107 + MATRIX_KEY(0x00, 0x08, KEY_9) 108 + >; 109 + }; 110 + }; 111 + ...
-46
Documentation/devicetree/bindings/input/hid-over-i2c.txt
··· 1 - * HID over I2C Device-Tree bindings 2 - 3 - HID over I2C provides support for various Human Interface Devices over the 4 - I2C bus. These devices can be for example touchpads, keyboards, touch screens 5 - or sensors. 6 - 7 - The specification has been written by Microsoft and is currently available here: 8 - http://msdn.microsoft.com/en-us/library/windows/hardware/hh852380.aspx 9 - 10 - If this binding is used, the kernel module i2c-hid will handle the communication 11 - with the device and the generic hid core layer will handle the protocol. 12 - 13 - Required properties: 14 - - compatible: must be "hid-over-i2c" 15 - - reg: i2c slave address 16 - - hid-descr-addr: HID descriptor address 17 - - interrupts: interrupt line 18 - 19 - Additional optional properties: 20 - 21 - Some devices may support additional optional properties to help with, e.g., 22 - power sequencing. The following properties can be supported by one or more 23 - device-specific compatible properties, which should be used in addition to the 24 - "hid-over-i2c" string. 25 - 26 - - compatible: 27 - * "wacom,w9013" (Wacom W9013 digitizer). Supports: 28 - - vdd-supply (3.3V) 29 - - vddl-supply (1.8V) 30 - - post-power-on-delay-ms 31 - 32 - - vdd-supply: phandle of the regulator that provides the supply voltage. 33 - - post-power-on-delay-ms: time required by the device after enabling its regulators 34 - or powering it on, before it is ready for communication. 35 - - touchscreen-inverted-x: See touchscreen.txt 36 - - touchscreen-inverted-y: See touchscreen.txt 37 - 38 - Example: 39 - 40 - i2c-hid-dev@2c { 41 - compatible = "hid-over-i2c"; 42 - reg = <0x2c>; 43 - hid-descr-addr = <0x0020>; 44 - interrupt-parent = <&gpx3>; 45 - interrupts = <3 2>; 46 - };
+83
Documentation/devicetree/bindings/input/hid-over-i2c.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/input/hid-over-i2c.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: HID over I2C Devices 8 + 9 + maintainers: 10 + - Benjamin Tissoires <benjamin.tissoires@redhat.com> 11 + - Jiri Kosina <jkosina@suse.cz> 12 + 13 + description: |+ 14 + HID over I2C provides support for various Human Interface Devices over the 15 + I2C bus. These devices can be for example touchpads, keyboards, touch screens 16 + or sensors. 17 + 18 + The specification has been written by Microsoft and is currently available here: 19 + https://msdn.microsoft.com/en-us/library/windows/hardware/hh852380.aspx 20 + 21 + If this binding is used, the kernel module i2c-hid will handle the communication 22 + with the device and the generic hid core layer will handle the protocol. 23 + 24 + allOf: 25 + - $ref: /schemas/input/touchscreen/touchscreen.yaml# 26 + 27 + properties: 28 + compatible: 29 + oneOf: 30 + - items: 31 + - enum: 32 + - wacom,w9013 33 + - const: hid-over-i2c 34 + - description: Just "hid-over-i2c" alone is allowed, but not recommended. 35 + const: hid-over-i2c 36 + 37 + reg: 38 + maxItems: 1 39 + 40 + interrupts: 41 + maxItems: 1 42 + 43 + hid-descr-addr: 44 + description: HID descriptor address 45 + $ref: /schemas/types.yaml#/definitions/uint32 46 + 47 + post-power-on-delay-ms: 48 + description: Time required by the device after enabling its regulators 49 + or powering it on, before it is ready for communication. 50 + 51 + touchscreen-inverted-x: true 52 + 53 + touchscreen-inverted-y: true 54 + 55 + vdd-supply: 56 + description: 3.3V supply 57 + 58 + vddl-supply: 59 + description: 1.8V supply 60 + 61 + wakeup-source: true 62 + 63 + required: 64 + - compatible 65 + - reg 66 + - interrupts 67 + 68 + additionalProperties: false 69 + 70 + examples: 71 + - | 72 + i2c { 73 + #address-cells = <1>; 74 + #size-cells = <0>; 75 + 76 + hid@2c { 77 + compatible = "hid-over-i2c"; 78 + reg = <0x2c>; 79 + hid-descr-addr = <0x0020>; 80 + interrupts = <3 2>; 81 + }; 82 + }; 83 + ...
+50
Documentation/devicetree/bindings/input/ibm,op-panel.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/input/ibm,op-panel.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: IBM Operation Panel 8 + 9 + maintainers: 10 + - Eddie James <eajames@linux.ibm.com> 11 + 12 + allOf: 13 + - $ref: input.yaml# 14 + 15 + description: | 16 + The IBM Operation Panel provides a simple interface to control the connected 17 + server. It has a display and three buttons: two directional arrows and one 18 + 'Enter' button. 19 + 20 + properties: 21 + compatible: 22 + const: ibm,op-panel 23 + 24 + reg: 25 + maxItems: 1 26 + 27 + linux,keycodes: 28 + minItems: 1 29 + maxItems: 3 30 + 31 + required: 32 + - compatible 33 + - reg 34 + 35 + additionalProperties: false 36 + 37 + examples: 38 + - | 39 + #include <dt-bindings/i2c/i2c.h> 40 + #include <dt-bindings/input/input.h> 41 + i2c { 42 + #address-cells = <1>; 43 + #size-cells = <0>; 44 + 45 + ibm-op-panel@62 { 46 + compatible = "ibm,op-panel"; 47 + reg = <(0x62 | I2C_OWN_SLAVE_ADDRESS)>; 48 + linux,keycodes = <KEY_UP>, <KEY_DOWN>, <KEY_ENTER>; 49 + }; 50 + };
+7 -1
Documentation/devicetree/bindings/input/mediatek,mt6779-keypad.yaml
··· 49 49 maximum: 256 50 50 default: 16 51 51 52 + mediatek,keys-per-group: 53 + description: each (row, column) group has multiple keys 54 + $ref: /schemas/types.yaml#/definitions/uint32 55 + default: 1 56 + maximum: 2 57 + 52 58 required: 53 59 - compatible 54 60 - reg ··· 62 56 - clocks 63 57 - clock-names 64 58 65 - additionalProperties: false 59 + unevaluatedProperties: false 66 60 67 61 examples: 68 62 - |
+114
Documentation/devicetree/bindings/input/mediatek,pmic-keys.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/input/mediatek,pmic-keys.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: MediaTek PMIC Keys 8 + 9 + maintainers: 10 + - Chen Zhong <chen.zhong@mediatek.com> 11 + 12 + allOf: 13 + - $ref: input.yaml# 14 + 15 + description: | 16 + There are two key functions provided by MT6397, MT6323 and other MediaTek 17 + PMICs: pwrkey and homekey. 18 + The key functions are defined as the subnode of the function node provided 19 + by the PMIC that is defined as a Multi-Function Device (MFD). 20 + 21 + For MediaTek MT6323/MT6397 PMIC bindings see 22 + Documentation/devicetree/bindings/mfd/mt6397.txt 23 + 24 + properties: 25 + compatible: 26 + enum: 27 + - mediatek,mt6323-keys 28 + - mediatek,mt6331-keys 29 + - mediatek,mt6358-keys 30 + - mediatek,mt6397-keys 31 + 32 + power-off-time-sec: true 33 + 34 + mediatek,long-press-mode: 35 + description: | 36 + Key long-press force shutdown setting 37 + 0 - disabled 38 + 1 - pwrkey 39 + 2 - pwrkey+homekey 40 + $ref: /schemas/types.yaml#/definitions/uint32 41 + default: 0 42 + maximum: 2 43 + 44 + patternProperties: 45 + "^((power|home)|(key-[a-z0-9-]+|[a-z0-9-]+-key))$": 46 + $ref: input.yaml# 47 + 48 + properties: 49 + interrupts: 50 + minItems: 1 51 + items: 52 + - description: Key press interrupt 53 + - description: Key release interrupt 54 + 55 + interrupt-names: true 56 + 57 + linux-keycodes: 58 + maxItems: 1 59 + 60 + wakeup-source: true 61 + 62 + required: 63 + - linux,keycodes 64 + 65 + if: 66 + properties: 67 + interrupt-names: 68 + contains: 69 + const: powerkey 70 + then: 71 + properties: 72 + interrupt-names: 73 + minItems: 1 74 + items: 75 + - const: powerkey 76 + - const: powerkey_r 77 + else: 78 + properties: 79 + interrupt-names: 80 + minItems: 1 81 + items: 82 + - const: homekey 83 + - const: homekey_r 84 + 85 + unevaluatedProperties: false 86 + 87 + required: 88 + - compatible 89 + 90 + unevaluatedProperties: false 91 + 92 + examples: 93 + - | 94 + #include <dt-bindings/input/input.h> 95 + #include <dt-bindings/interrupt-controller/arm-gic.h> 96 + 97 + pmic { 98 + compatible = "mediatek,mt6397"; 99 + 100 + keys { 101 + compatible = "mediatek,mt6397-keys"; 102 + mediatek,long-press-mode = <1>; 103 + power-off-time-sec = <0>; 104 + 105 + key-power { 106 + linux,keycodes = <KEY_POWER>; 107 + wakeup-source; 108 + }; 109 + 110 + key-home { 111 + linux,keycodes = <KEY_VOLUMEDOWN>; 112 + }; 113 + }; 114 + };
-46
Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
··· 1 - MediaTek MT6397/MT6323 PMIC Keys Device Driver 2 - 3 - There are two key functions provided by MT6397/MT6323 PMIC, pwrkey 4 - and homekey. The key functions are defined as the subnode of the function 5 - node provided by MT6397/MT6323 PMIC that is being defined as one kind 6 - of Muti-Function Device (MFD) 7 - 8 - For MT6397/MT6323 MFD bindings see: 9 - Documentation/devicetree/bindings/mfd/mt6397.txt 10 - 11 - Required properties: 12 - - compatible: Should be one of: 13 - - "mediatek,mt6397-keys" 14 - - "mediatek,mt6323-keys" 15 - - "mediatek,mt6358-keys" 16 - - linux,keycodes: See Documentation/devicetree/bindings/input/input.yaml 17 - 18 - Optional Properties: 19 - - wakeup-source: See Documentation/devicetree/bindings/power/wakeup-source.txt 20 - - mediatek,long-press-mode: Long press key shutdown setting, 1 for 21 - pwrkey only, 2 for pwrkey/homekey together, others for disabled. 22 - - power-off-time-sec: See Documentation/devicetree/bindings/input/input.yaml 23 - 24 - Example: 25 - 26 - pmic: mt6397 { 27 - compatible = "mediatek,mt6397"; 28 - 29 - ... 30 - 31 - mt6397keys: mt6397keys { 32 - compatible = "mediatek,mt6397-keys"; 33 - mediatek,long-press-mode = <1>; 34 - power-off-time-sec = <0>; 35 - 36 - power { 37 - linux,keycodes = <116>; 38 - wakeup-source; 39 - }; 40 - 41 - home { 42 - linux,keycodes = <114>; 43 - }; 44 - }; 45 - 46 - };
+66
Documentation/devicetree/bindings/input/pine64,pinephone-keyboard.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/pine64,pinephone-keyboard.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Pine64 PinePhone keyboard device tree bindings 8 + 9 + maintainers: 10 + - Samuel Holland <samuel@sholland.org> 11 + 12 + description: 13 + A keyboard accessory is available for the Pine64 PinePhone and PinePhone Pro. 14 + It connects via I2C, providing a raw scan matrix, a flashing interface, and a 15 + subordinate I2C bus for communication with a battery charger IC. 16 + 17 + properties: 18 + compatible: 19 + const: pine64,pinephone-keyboard 20 + 21 + reg: 22 + const: 0x15 23 + 24 + interrupts: 25 + maxItems: 1 26 + 27 + vbat-supply: 28 + description: Supply for the keyboard MCU 29 + 30 + wakeup-source: true 31 + 32 + i2c: 33 + $ref: /schemas/i2c/i2c-controller.yaml# 34 + 35 + required: 36 + - compatible 37 + - reg 38 + - interrupts 39 + 40 + additionalProperties: false 41 + 42 + examples: 43 + - | 44 + #include <dt-bindings/input/input.h> 45 + #include <dt-bindings/interrupt-controller/irq.h> 46 + 47 + i2c { 48 + #address-cells = <1>; 49 + #size-cells = <0>; 50 + 51 + keyboard@15 { 52 + compatible = "pine64,pinephone-keyboard"; 53 + reg = <0x15>; 54 + interrupt-parent = <&r_pio>; 55 + interrupts = <0 12 IRQ_TYPE_EDGE_FALLING>; /* PL12 */ 56 + 57 + i2c { 58 + #address-cells = <1>; 59 + #size-cells = <0>; 60 + 61 + charger@75 { 62 + reg = <0x75>; 63 + }; 64 + }; 65 + }; 66 + };
-23
Documentation/devicetree/bindings/input/qcom,pm8xxx-vib.txt
··· 1 - Qualcomm PM8xxx PMIC Vibrator 2 - 3 - PROPERTIES 4 - 5 - - compatible: 6 - Usage: required 7 - Value type: <string> 8 - Definition: must be one of: 9 - "qcom,pm8058-vib" 10 - "qcom,pm8916-vib" 11 - "qcom,pm8921-vib" 12 - 13 - - reg: 14 - Usage: required 15 - Value type: <prop-encoded-array> 16 - Definition: address of vibration control register 17 - 18 - EXAMPLE 19 - 20 - vibrator@4a { 21 - compatible = "qcom,pm8058-vib"; 22 - reg = <0x4a>; 23 - };
+38
Documentation/devicetree/bindings/input/qcom,pm8xxx-vib.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/input/qcom,pm8xxx-vib.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm PM8xxx PMIC Vibrator 8 + 9 + maintainers: 10 + - Bjorn Andersson <andersson@kernel.org> 11 + 12 + properties: 13 + compatible: 14 + enum: 15 + - qcom,pm8058-vib 16 + - qcom,pm8916-vib 17 + - qcom,pm8921-vib 18 + 19 + reg: 20 + maxItems: 1 21 + 22 + required: 23 + - compatible 24 + - reg 25 + 26 + additionalProperties: false 27 + 28 + examples: 29 + - | 30 + pmic { 31 + #address-cells = <1>; 32 + #size-cells = <0>; 33 + 34 + vibrator@4a { 35 + compatible = "qcom,pm8058-vib"; 36 + reg = <0x4a>; 37 + }; 38 + };
+3 -3
Documentation/devicetree/bindings/input/touchscreen/auo_pixcir_ts.txt
··· 17 17 auo_pixcir_ts@5c { 18 18 compatible = "auo,auo_pixcir_ts"; 19 19 reg = <0x5c>; 20 - interrupts = <2 0>; 20 + interrupts = <2 IRQ_TYPE_LEVEL_HIGH>; 21 21 22 - gpios = <&gpf 2 0 2>, /* INT */ 23 - <&gpf 5 1 0>; /* RST */ 22 + gpios = <&gpf 2 0 GPIO_LEVEL_HIGH>, /* INT */ 23 + <&gpf 5 1 GPIO_LEVEL_LOW>; /* RST */ 24 24 25 25 x-size = <800>; 26 26 y-size = <600>;
+8 -8
Documentation/devicetree/bindings/input/touchscreen/colibri-vf50-ts.txt
··· 3 3 Required Properties: 4 4 - compatible must be toradex,vf50-touchscreen 5 5 - io-channels: adc channels being used by the Colibri VF50 module 6 + IIO ADC for Y-, X-, Y+, X+ connections 6 7 - xp-gpios: FET gate driver for input of X+ 7 8 - xm-gpios: FET gate driver for input of X- 8 9 - yp-gpios: FET gate driver for input of Y+ 9 10 - ym-gpios: FET gate driver for input of Y- 10 - - interrupts: pen irq interrupt for touch detection 11 - - pinctrl-names: "idle", "default", "gpios" 12 - - pinctrl-0: pinctrl node for pen/touch detection state pinmux 11 + - interrupts: pen irq interrupt for touch detection, signal from X plate 12 + - pinctrl-names: "idle", "default" 13 + - pinctrl-0: pinctrl node for pen/touch detection, pinctrl must provide 14 + pull-up resistor on X+, X-. 13 15 - pinctrl-1: pinctrl node for X/Y and pressure measurement (ADC) state pinmux 14 - - pinctrl-2: pinctrl node for gpios functioning as FET gate drivers 15 16 - vf50-ts-min-pressure: pressure level at which to stop measuring X/Y values 16 17 17 18 Example: ··· 27 26 ym-gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>; 28 27 interrupt-parent = <&gpio0>; 29 28 interrupts = <8 IRQ_TYPE_LEVEL_LOW>; 30 - pinctrl-names = "idle","default","gpios"; 31 - pinctrl-0 = <&pinctrl_touchctrl_idle>; 32 - pinctrl-1 = <&pinctrl_touchctrl_default>; 33 - pinctrl-2 = <&pinctrl_touchctrl_gpios>; 29 + pinctrl-names = "idle","default"; 30 + pinctrl-0 = <&pinctrl_touchctrl_idle>, <&pinctrl_touchctrl_gpios>; 31 + pinctrl-1 = <&pinctrl_touchctrl_default>, <&pinctrl_touchctrl_gpios>; 34 32 vf50-ts-min-pressure = <200>; 35 33 };
+7 -3
Documentation/devicetree/bindings/input/touchscreen/elan,elants_i2c.yaml
··· 14 14 15 15 properties: 16 16 compatible: 17 - enum: 18 - - elan,ektf3624 19 - - elan,ekth3500 17 + oneOf: 18 + - enum: 19 + - elan,ektf3624 20 + - elan,ekth3500 21 + - items: 22 + - const: elan,ekth3915 23 + - const: elan,ekth3500 20 24 21 25 reg: 22 26 maxItems: 1
+1 -2
Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
··· 54 54 1 -> 3.25 MHz 55 55 2 || 3 -> 6.5 MHz 56 56 57 - Node name must be stmpe_touchscreen and should be child node of stmpe node to 58 - which it belongs. 57 + Node should be child node of stmpe node to which it belongs. 59 58 60 59 Note that common ADC settings of stmpe_touchscreen (child) will take precedence 61 60 over the settings done in MFD.
+6
Documentation/input/event-codes.rst
··· 235 235 BTN_TOOL_<name> signals the type of tool that is currently detected by the 236 236 hardware and is otherwise independent of ABS_DISTANCE and/or BTN_TOUCH. 237 237 238 + * ABS_PROFILE: 239 + 240 + - Used to describe the state of a multi-value profile switch. An event is 241 + emitted only when the selected profile changes, indicating the newly 242 + selected profile value. 243 + 238 244 * ABS_MT_<name>: 239 245 240 246 - Used to describe multitouch input events. Please see
+6
Documentation/input/gamepad.rst
··· 189 189 - Rumble: 190 190 191 191 Rumble is advertised as FF_RUMBLE. 192 + 193 + - Profile: 194 + 195 + Some pads provide a multi-value profile selection switch. An example is the 196 + XBox Adaptive and the XBox Elite 2 controllers. When the active profile is 197 + switched, its newly selected value is emitted as an ABS_PROFILE event.
+20 -1
MAINTAINERS
··· 554 554 S: Supported 555 555 W: http://wiki.analog.com/ADP5588 556 556 W: https://ez.analog.com/linux-software-drivers 557 - F: drivers/gpio/gpio-adp5588.c 557 + F: Documentation/devicetree/bindings/input/adi,adp5588.yaml 558 558 F: drivers/input/keyboard/adp5588-keys.c 559 559 560 560 ADP8860 BACKLIGHT DRIVER (ADP8860/ADP8861/ADP8863) ··· 9713 9713 F: Documentation/ia64/ 9714 9714 F: arch/ia64/ 9715 9715 9716 + IBM Operation Panel Input Driver 9717 + M: Eddie James <eajames@linux.ibm.com> 9718 + L: linux-input@vger.kernel.org 9719 + S: Maintained 9720 + F: Documentation/devicetree/bindings/input/ibm,op-panel.yaml 9721 + F: drivers/input/misc/ibm-panel.c 9722 + 9716 9723 IBM Power 842 compression accelerator 9717 9724 M: Haren Myneni <haren@us.ibm.com> 9718 9725 S: Supported ··· 12931 12924 S: Supported 12932 12925 F: Documentation/devicetree/bindings/media/mediatek-jpeg-*.yaml 12933 12926 F: drivers/media/platform/mediatek/jpeg/ 12927 + 12928 + MEDIATEK KEYPAD DRIVER 12929 + M: Mattijs Korpershoek <mkorpershoek@baylibre.com> 12930 + S: Supported 12931 + F: Documentation/devicetree/bindings/input/mediatek,mt6779-keypad.yaml 12932 + F: drivers/input/keyboard/mt6779-keypad.c 12934 12933 12935 12934 MEDIATEK MDP DRIVER 12936 12935 M: Minghsiu Tsai <minghsiu.tsai@mediatek.com> ··· 16349 16336 F: Documentation/devicetree/bindings/pinctrl/sunplus,* 16350 16337 F: drivers/pinctrl/sunplus/ 16351 16338 F: include/dt-bindings/pinctrl/sppctl*.h 16339 + 16340 + PINE64 PINEPHONE KEYBOARD DRIVER 16341 + M: Samuel Holland <samuel@sholland.org> 16342 + S: Supported 16343 + F: Documentation/devicetree/bindings/input/pine64,pinephone-keyboard.yaml 16344 + F: drivers/input/keyboard/pinephone-keyboard.c 16352 16345 16353 16346 PKTCDVD DRIVER 16354 16347 M: linux-block@vger.kernel.org
-14
drivers/gpio/Kconfig
··· 990 990 menu "I2C GPIO expanders" 991 991 depends on I2C 992 992 993 - config GPIO_ADP5588 994 - tristate "ADP5588 I2C GPIO expander" 995 - help 996 - This option enables support for 18 GPIOs found 997 - on Analog Devices ADP5588 GPIO Expanders. 998 - 999 - config GPIO_ADP5588_IRQ 1000 - bool "Interrupt controller support for ADP5588" 1001 - depends on GPIO_ADP5588=y 1002 - select GPIOLIB_IRQCHIP 1003 - help 1004 - Say yes here to enable the adp5588 to be used as an interrupt 1005 - controller. It requires the driver to be built in the kernel. 1006 - 1007 993 config GPIO_ADNP 1008 994 tristate "Avionic Design N-bit GPIO expander" 1009 995 depends on OF_GPIO
-1
drivers/gpio/Makefile
··· 25 25 obj-$(CONFIG_GPIO_74XX_MMIO) += gpio-74xx-mmio.o 26 26 obj-$(CONFIG_GPIO_ADNP) += gpio-adnp.o 27 27 obj-$(CONFIG_GPIO_ADP5520) += gpio-adp5520.o 28 - obj-$(CONFIG_GPIO_ADP5588) += gpio-adp5588.o 29 28 obj-$(CONFIG_GPIO_AGGREGATOR) += gpio-aggregator.o 30 29 obj-$(CONFIG_GPIO_ALTERA_A10SR) += gpio-altera-a10sr.o 31 30 obj-$(CONFIG_GPIO_ALTERA) += gpio-altera.o
-446
drivers/gpio/gpio-adp5588.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * GPIO Chip driver for Analog Devices 4 - * ADP5588/ADP5587 I/O Expander and QWERTY Keypad Controller 5 - * 6 - * Copyright 2009-2010 Analog Devices Inc. 7 - */ 8 - 9 - #include <linux/gpio/driver.h> 10 - #include <linux/i2c.h> 11 - #include <linux/init.h> 12 - #include <linux/interrupt.h> 13 - #include <linux/irq.h> 14 - #include <linux/kernel.h> 15 - #include <linux/mod_devicetable.h> 16 - #include <linux/module.h> 17 - #include <linux/slab.h> 18 - 19 - #include <linux/platform_data/adp5588.h> 20 - 21 - /* 22 - * Early pre 4.0 Silicon required to delay readout by at least 25ms, 23 - * since the Event Counter Register updated 25ms after the interrupt 24 - * asserted. 25 - */ 26 - #define WA_DELAYED_READOUT_REVID(rev) ((rev) < 4) 27 - 28 - struct adp5588_gpio { 29 - struct i2c_client *client; 30 - struct gpio_chip gpio_chip; 31 - struct mutex lock; /* protect cached dir, dat_out */ 32 - /* protect serialized access to the interrupt controller bus */ 33 - struct mutex irq_lock; 34 - uint8_t dat_out[3]; 35 - uint8_t dir[3]; 36 - uint8_t int_lvl_low[3]; 37 - uint8_t int_lvl_high[3]; 38 - uint8_t int_en[3]; 39 - uint8_t irq_mask[3]; 40 - uint8_t int_input_en[3]; 41 - }; 42 - 43 - static int adp5588_gpio_read(struct i2c_client *client, u8 reg) 44 - { 45 - int ret = i2c_smbus_read_byte_data(client, reg); 46 - 47 - if (ret < 0) 48 - dev_err(&client->dev, "Read Error\n"); 49 - 50 - return ret; 51 - } 52 - 53 - static int adp5588_gpio_write(struct i2c_client *client, u8 reg, u8 val) 54 - { 55 - int ret = i2c_smbus_write_byte_data(client, reg, val); 56 - 57 - if (ret < 0) 58 - dev_err(&client->dev, "Write Error\n"); 59 - 60 - return ret; 61 - } 62 - 63 - static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned off) 64 - { 65 - struct adp5588_gpio *dev = gpiochip_get_data(chip); 66 - unsigned bank = ADP5588_BANK(off); 67 - unsigned bit = ADP5588_BIT(off); 68 - int val; 69 - 70 - mutex_lock(&dev->lock); 71 - 72 - if (dev->dir[bank] & bit) 73 - val = dev->dat_out[bank]; 74 - else 75 - val = adp5588_gpio_read(dev->client, GPIO_DAT_STAT1 + bank); 76 - 77 - mutex_unlock(&dev->lock); 78 - 79 - return !!(val & bit); 80 - } 81 - 82 - static void adp5588_gpio_set_value(struct gpio_chip *chip, 83 - unsigned off, int val) 84 - { 85 - unsigned bank, bit; 86 - struct adp5588_gpio *dev = gpiochip_get_data(chip); 87 - 88 - bank = ADP5588_BANK(off); 89 - bit = ADP5588_BIT(off); 90 - 91 - mutex_lock(&dev->lock); 92 - if (val) 93 - dev->dat_out[bank] |= bit; 94 - else 95 - dev->dat_out[bank] &= ~bit; 96 - 97 - adp5588_gpio_write(dev->client, GPIO_DAT_OUT1 + bank, 98 - dev->dat_out[bank]); 99 - mutex_unlock(&dev->lock); 100 - } 101 - 102 - static int adp5588_gpio_direction_input(struct gpio_chip *chip, unsigned off) 103 - { 104 - int ret; 105 - unsigned bank; 106 - struct adp5588_gpio *dev = gpiochip_get_data(chip); 107 - 108 - bank = ADP5588_BANK(off); 109 - 110 - mutex_lock(&dev->lock); 111 - dev->dir[bank] &= ~ADP5588_BIT(off); 112 - ret = adp5588_gpio_write(dev->client, GPIO_DIR1 + bank, dev->dir[bank]); 113 - mutex_unlock(&dev->lock); 114 - 115 - return ret; 116 - } 117 - 118 - static int adp5588_gpio_direction_output(struct gpio_chip *chip, 119 - unsigned off, int val) 120 - { 121 - int ret; 122 - unsigned bank, bit; 123 - struct adp5588_gpio *dev = gpiochip_get_data(chip); 124 - 125 - bank = ADP5588_BANK(off); 126 - bit = ADP5588_BIT(off); 127 - 128 - mutex_lock(&dev->lock); 129 - dev->dir[bank] |= bit; 130 - 131 - if (val) 132 - dev->dat_out[bank] |= bit; 133 - else 134 - dev->dat_out[bank] &= ~bit; 135 - 136 - ret = adp5588_gpio_write(dev->client, GPIO_DAT_OUT1 + bank, 137 - dev->dat_out[bank]); 138 - ret |= adp5588_gpio_write(dev->client, GPIO_DIR1 + bank, 139 - dev->dir[bank]); 140 - mutex_unlock(&dev->lock); 141 - 142 - return ret; 143 - } 144 - 145 - #ifdef CONFIG_GPIO_ADP5588_IRQ 146 - 147 - static void adp5588_irq_bus_lock(struct irq_data *d) 148 - { 149 - struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 150 - struct adp5588_gpio *dev = gpiochip_get_data(gc); 151 - 152 - mutex_lock(&dev->irq_lock); 153 - } 154 - 155 - /* 156 - * genirq core code can issue chip->mask/unmask from atomic context. 157 - * This doesn't work for slow busses where an access needs to sleep. 158 - * bus_sync_unlock() is therefore called outside the atomic context, 159 - * syncs the current irq mask state with the slow external controller 160 - * and unlocks the bus. 161 - */ 162 - 163 - static void adp5588_irq_bus_sync_unlock(struct irq_data *d) 164 - { 165 - struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 166 - struct adp5588_gpio *dev = gpiochip_get_data(gc); 167 - int i; 168 - 169 - for (i = 0; i <= ADP5588_BANK(ADP5588_MAXGPIO); i++) { 170 - if (dev->int_input_en[i]) { 171 - mutex_lock(&dev->lock); 172 - dev->dir[i] &= ~dev->int_input_en[i]; 173 - dev->int_input_en[i] = 0; 174 - adp5588_gpio_write(dev->client, GPIO_DIR1 + i, 175 - dev->dir[i]); 176 - mutex_unlock(&dev->lock); 177 - } 178 - 179 - if (dev->int_en[i] ^ dev->irq_mask[i]) { 180 - dev->int_en[i] = dev->irq_mask[i]; 181 - adp5588_gpio_write(dev->client, GPI_EM1 + i, 182 - dev->int_en[i]); 183 - } 184 - } 185 - 186 - mutex_unlock(&dev->irq_lock); 187 - } 188 - 189 - static void adp5588_irq_mask(struct irq_data *d) 190 - { 191 - struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 192 - struct adp5588_gpio *dev = gpiochip_get_data(gc); 193 - 194 - dev->irq_mask[ADP5588_BANK(d->hwirq)] &= ~ADP5588_BIT(d->hwirq); 195 - } 196 - 197 - static void adp5588_irq_unmask(struct irq_data *d) 198 - { 199 - struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 200 - struct adp5588_gpio *dev = gpiochip_get_data(gc); 201 - 202 - dev->irq_mask[ADP5588_BANK(d->hwirq)] |= ADP5588_BIT(d->hwirq); 203 - } 204 - 205 - static int adp5588_irq_set_type(struct irq_data *d, unsigned int type) 206 - { 207 - struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 208 - struct adp5588_gpio *dev = gpiochip_get_data(gc); 209 - uint16_t gpio = d->hwirq; 210 - unsigned bank, bit; 211 - 212 - bank = ADP5588_BANK(gpio); 213 - bit = ADP5588_BIT(gpio); 214 - 215 - dev->int_lvl_low[bank] &= ~bit; 216 - dev->int_lvl_high[bank] &= ~bit; 217 - 218 - if (type & IRQ_TYPE_EDGE_BOTH || type & IRQ_TYPE_LEVEL_HIGH) 219 - dev->int_lvl_high[bank] |= bit; 220 - 221 - if (type & IRQ_TYPE_EDGE_BOTH || type & IRQ_TYPE_LEVEL_LOW) 222 - dev->int_lvl_low[bank] |= bit; 223 - 224 - dev->int_input_en[bank] |= bit; 225 - 226 - return 0; 227 - } 228 - 229 - static struct irq_chip adp5588_irq_chip = { 230 - .name = "adp5588", 231 - .irq_mask = adp5588_irq_mask, 232 - .irq_unmask = adp5588_irq_unmask, 233 - .irq_bus_lock = adp5588_irq_bus_lock, 234 - .irq_bus_sync_unlock = adp5588_irq_bus_sync_unlock, 235 - .irq_set_type = adp5588_irq_set_type, 236 - }; 237 - 238 - static irqreturn_t adp5588_irq_handler(int irq, void *devid) 239 - { 240 - struct adp5588_gpio *dev = devid; 241 - int status = adp5588_gpio_read(dev->client, INT_STAT); 242 - 243 - if (status & ADP5588_KE_INT) { 244 - int ev_cnt = adp5588_gpio_read(dev->client, KEY_LCK_EC_STAT); 245 - 246 - if (ev_cnt > 0) { 247 - int i; 248 - 249 - for (i = 0; i < (ev_cnt & ADP5588_KEC); i++) { 250 - int key = adp5588_gpio_read(dev->client, 251 - Key_EVENTA + i); 252 - /* GPIN events begin at 97, 253 - * bit 7 indicates logic level 254 - */ 255 - int gpio = (key & 0x7f) - 97; 256 - int lvl = key & (1 << 7); 257 - int bank = ADP5588_BANK(gpio); 258 - int bit = ADP5588_BIT(gpio); 259 - 260 - if ((lvl && dev->int_lvl_high[bank] & bit) || 261 - (!lvl && dev->int_lvl_low[bank] & bit)) 262 - handle_nested_irq(irq_find_mapping( 263 - dev->gpio_chip.irq.domain, gpio)); 264 - } 265 - } 266 - } 267 - 268 - adp5588_gpio_write(dev->client, INT_STAT, status); /* Status is W1C */ 269 - 270 - return IRQ_HANDLED; 271 - } 272 - 273 - 274 - static int adp5588_irq_init_hw(struct gpio_chip *gc) 275 - { 276 - struct adp5588_gpio *dev = gpiochip_get_data(gc); 277 - /* Enable IRQs after registering chip */ 278 - adp5588_gpio_write(dev->client, CFG, 279 - ADP5588_AUTO_INC | ADP5588_INT_CFG | ADP5588_KE_IEN); 280 - 281 - return 0; 282 - } 283 - 284 - static int adp5588_irq_setup(struct adp5588_gpio *dev) 285 - { 286 - struct i2c_client *client = dev->client; 287 - int ret; 288 - struct adp5588_gpio_platform_data *pdata = 289 - dev_get_platdata(&client->dev); 290 - struct gpio_irq_chip *girq; 291 - 292 - adp5588_gpio_write(client, CFG, ADP5588_AUTO_INC); 293 - adp5588_gpio_write(client, INT_STAT, -1); /* status is W1C */ 294 - 295 - mutex_init(&dev->irq_lock); 296 - 297 - ret = devm_request_threaded_irq(&client->dev, client->irq, 298 - NULL, adp5588_irq_handler, IRQF_ONESHOT 299 - | IRQF_TRIGGER_FALLING | IRQF_SHARED, 300 - dev_name(&client->dev), dev); 301 - if (ret) { 302 - dev_err(&client->dev, "failed to request irq %d\n", 303 - client->irq); 304 - return ret; 305 - } 306 - 307 - /* This will be registered in the call to devm_gpiochip_add_data() */ 308 - girq = &dev->gpio_chip.irq; 309 - girq->chip = &adp5588_irq_chip; 310 - /* This will let us handle the parent IRQ in the driver */ 311 - girq->parent_handler = NULL; 312 - girq->num_parents = 0; 313 - girq->parents = NULL; 314 - girq->first = pdata ? pdata->irq_base : 0; 315 - girq->default_type = IRQ_TYPE_NONE; 316 - girq->handler = handle_simple_irq; 317 - girq->init_hw = adp5588_irq_init_hw; 318 - girq->threaded = true; 319 - 320 - return 0; 321 - } 322 - 323 - #else 324 - static int adp5588_irq_setup(struct adp5588_gpio *dev) 325 - { 326 - struct i2c_client *client = dev->client; 327 - dev_warn(&client->dev, "interrupt support not compiled in\n"); 328 - 329 - return 0; 330 - } 331 - 332 - #endif /* CONFIG_GPIO_ADP5588_IRQ */ 333 - 334 - static int adp5588_gpio_probe(struct i2c_client *client) 335 - { 336 - struct adp5588_gpio_platform_data *pdata = 337 - dev_get_platdata(&client->dev); 338 - struct adp5588_gpio *dev; 339 - struct gpio_chip *gc; 340 - int ret, i, revid; 341 - unsigned int pullup_dis_mask = 0; 342 - 343 - if (!i2c_check_functionality(client->adapter, 344 - I2C_FUNC_SMBUS_BYTE_DATA)) { 345 - dev_err(&client->dev, "SMBUS Byte Data not Supported\n"); 346 - return -EIO; 347 - } 348 - 349 - dev = devm_kzalloc(&client->dev, sizeof(*dev), GFP_KERNEL); 350 - if (!dev) 351 - return -ENOMEM; 352 - 353 - dev->client = client; 354 - 355 - gc = &dev->gpio_chip; 356 - gc->direction_input = adp5588_gpio_direction_input; 357 - gc->direction_output = adp5588_gpio_direction_output; 358 - gc->get = adp5588_gpio_get_value; 359 - gc->set = adp5588_gpio_set_value; 360 - gc->can_sleep = true; 361 - gc->base = -1; 362 - gc->parent = &client->dev; 363 - 364 - if (pdata) { 365 - gc->base = pdata->gpio_start; 366 - gc->names = pdata->names; 367 - pullup_dis_mask = pdata->pullup_dis_mask; 368 - } 369 - 370 - gc->ngpio = ADP5588_MAXGPIO; 371 - gc->label = client->name; 372 - gc->owner = THIS_MODULE; 373 - 374 - mutex_init(&dev->lock); 375 - 376 - ret = adp5588_gpio_read(dev->client, DEV_ID); 377 - if (ret < 0) 378 - return ret; 379 - 380 - revid = ret & ADP5588_DEVICE_ID_MASK; 381 - 382 - for (i = 0, ret = 0; i <= ADP5588_BANK(ADP5588_MAXGPIO); i++) { 383 - dev->dat_out[i] = adp5588_gpio_read(client, GPIO_DAT_OUT1 + i); 384 - dev->dir[i] = adp5588_gpio_read(client, GPIO_DIR1 + i); 385 - ret |= adp5588_gpio_write(client, KP_GPIO1 + i, 0); 386 - ret |= adp5588_gpio_write(client, GPIO_PULL1 + i, 387 - (pullup_dis_mask >> (8 * i)) & 0xFF); 388 - ret |= adp5588_gpio_write(client, GPIO_INT_EN1 + i, 0); 389 - if (ret) 390 - return ret; 391 - } 392 - 393 - if (client->irq) { 394 - if (WA_DELAYED_READOUT_REVID(revid)) { 395 - dev_warn(&client->dev, "GPIO int not supported\n"); 396 - } else { 397 - ret = adp5588_irq_setup(dev); 398 - if (ret) 399 - return ret; 400 - } 401 - } 402 - 403 - ret = devm_gpiochip_add_data(&client->dev, &dev->gpio_chip, dev); 404 - if (ret) 405 - return ret; 406 - 407 - i2c_set_clientdata(client, dev); 408 - 409 - return 0; 410 - } 411 - 412 - static void adp5588_gpio_remove(struct i2c_client *client) 413 - { 414 - struct adp5588_gpio *dev = i2c_get_clientdata(client); 415 - 416 - if (dev->client->irq) 417 - free_irq(dev->client->irq, dev); 418 - } 419 - 420 - static const struct i2c_device_id adp5588_gpio_id[] = { 421 - { "adp5588-gpio" }, 422 - {} 423 - }; 424 - MODULE_DEVICE_TABLE(i2c, adp5588_gpio_id); 425 - 426 - static const struct of_device_id adp5588_gpio_of_id[] = { 427 - { .compatible = "adi,adp5588-gpio" }, 428 - {} 429 - }; 430 - MODULE_DEVICE_TABLE(of, adp5588_gpio_of_id); 431 - 432 - static struct i2c_driver adp5588_gpio_driver = { 433 - .driver = { 434 - .name = "adp5588-gpio", 435 - .of_match_table = adp5588_gpio_of_id, 436 - }, 437 - .probe_new = adp5588_gpio_probe, 438 - .remove = adp5588_gpio_remove, 439 - .id_table = adp5588_gpio_id, 440 - }; 441 - 442 - module_i2c_driver(adp5588_gpio_driver); 443 - 444 - MODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>"); 445 - MODULE_DESCRIPTION("GPIO ADP5588 Driver"); 446 - MODULE_LICENSE("GPL");
+2 -1
drivers/hid/hid-debug.c
··· 1014 1014 [ABS_HAT3Y] = "Hat 3Y", [ABS_PRESSURE] = "Pressure", 1015 1015 [ABS_DISTANCE] = "Distance", [ABS_TILT_X] = "XTilt", 1016 1016 [ABS_TILT_Y] = "YTilt", [ABS_TOOL_WIDTH] = "ToolWidth", 1017 - [ABS_VOLUME] = "Volume", [ABS_MISC] = "Misc", 1017 + [ABS_VOLUME] = "Volume", [ABS_PROFILE] = "Profile", 1018 + [ABS_MISC] = "Misc", 1018 1019 [ABS_MT_TOUCH_MAJOR] = "MTMajor", 1019 1020 [ABS_MT_TOUCH_MINOR] = "MTMinor", 1020 1021 [ABS_MT_WIDTH_MAJOR] = "MTMajorW",
-3
drivers/input/ff-core.c
··· 6 6 * Copyright (c) 2006 Dmitry Torokhov <dtor@mail.ru> 7 7 */ 8 8 9 - /* 10 - */ 11 - 12 9 /* #define DEBUG */ 13 10 14 11 #include <linux/input.h>
-3
drivers/input/ff-memless.c
··· 6 6 * Copyright (c) 2006 Dmitry Torokhov <dtor@mail.ru> 7 7 */ 8 8 9 - /* 10 - */ 11 - 12 9 /* #define DEBUG */ 13 10 14 11 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-3
drivers/input/gameport/emu10k1-gp.c
··· 7 7 * EMU10k1 - SB Live / Audigy - gameport driver for Linux 8 8 */ 9 9 10 - /* 11 - */ 12 - 13 10 #include <asm/io.h> 14 11 15 12 #include <linux/module.h>
-3
drivers/input/gameport/lightning.c
··· 7 7 * PDPI Lightning 4 gamecard driver for Linux. 8 8 */ 9 9 10 - /* 11 - */ 12 - 13 10 #include <asm/io.h> 14 11 #include <linux/delay.h> 15 12 #include <linux/errno.h>
-3
drivers/input/gameport/ns558.c
··· 8 8 * NS558 based standard IBM game port driver for Linux 9 9 */ 10 10 11 - /* 12 - */ 13 - 14 11 #include <asm/io.h> 15 12 16 13 #include <linux/module.h>
+1 -1
drivers/input/joydev.c
··· 746 746 } 747 747 748 748 /* 749 - * These codes are copied from from hid-ids.h, unfortunately there is no common 749 + * These codes are copied from hid-ids.h, unfortunately there is no common 750 750 * usb_ids/bt_ids.h header. 751 751 */ 752 752 #define USB_VENDOR_ID_SONY 0x054c
-3
drivers/input/joystick/a3d.c
··· 7 7 * FP-Gaming Assassin 3D joystick driver for Linux 8 8 */ 9 9 10 - /* 11 - */ 12 - 13 10 #include <linux/kernel.h> 14 11 #include <linux/module.h> 15 12 #include <linux/slab.h>
+53 -12
drivers/input/joystick/adc-joystick.c
··· 26 26 struct adc_joystick_axis *axes; 27 27 struct iio_channel *chans; 28 28 int num_chans; 29 + bool polled; 29 30 }; 31 + 32 + static void adc_joystick_poll(struct input_dev *input) 33 + { 34 + struct adc_joystick *joy = input_get_drvdata(input); 35 + int i, val, ret; 36 + 37 + for (i = 0; i < joy->num_chans; i++) { 38 + ret = iio_read_channel_raw(&joy->chans[i], &val); 39 + if (ret < 0) 40 + return; 41 + input_report_abs(input, joy->axes[i].code, val); 42 + } 43 + input_sync(input); 44 + } 30 45 31 46 static int adc_joystick_handle(const void *data, void *private) 32 47 { ··· 194 179 int error; 195 180 int bits; 196 181 int i; 182 + unsigned int poll_interval; 197 183 198 184 joy = devm_kzalloc(dev, sizeof(*joy), GFP_KERNEL); 199 185 if (!joy) ··· 208 192 return error; 209 193 } 210 194 211 - /* Count how many channels we got. NULL terminated. */ 195 + error = device_property_read_u32(dev, "poll-interval", &poll_interval); 196 + if (error) { 197 + /* -EINVAL means the property is absent. */ 198 + if (error != -EINVAL) 199 + return error; 200 + } else if (poll_interval == 0) { 201 + dev_err(dev, "Unable to get poll-interval\n"); 202 + return -EINVAL; 203 + } else { 204 + joy->polled = true; 205 + } 206 + 207 + /* 208 + * Count how many channels we got. NULL terminated. 209 + * Do not check the storage size if using polling. 210 + */ 212 211 for (i = 0; joy->chans[i].indio_dev; i++) { 212 + if (joy->polled) 213 + continue; 213 214 bits = joy->chans[i].channel->scan_type.storagebits; 214 215 if (!bits || bits > 16) { 215 216 dev_err(dev, "Unsupported channel storage size\n"); ··· 248 215 joy->input = input; 249 216 input->name = pdev->name; 250 217 input->id.bustype = BUS_HOST; 251 - input->open = adc_joystick_open; 252 - input->close = adc_joystick_close; 253 218 254 219 error = adc_joystick_set_axes(dev, joy); 255 220 if (error) 256 221 return error; 257 222 258 - joy->buffer = iio_channel_get_all_cb(dev, adc_joystick_handle, joy); 259 - if (IS_ERR(joy->buffer)) { 260 - dev_err(dev, "Unable to allocate callback buffer\n"); 261 - return PTR_ERR(joy->buffer); 262 - } 223 + if (joy->polled) { 224 + input_setup_polling(input, adc_joystick_poll); 225 + input_set_poll_interval(input, poll_interval); 226 + } else { 227 + input->open = adc_joystick_open; 228 + input->close = adc_joystick_close; 263 229 264 - error = devm_add_action_or_reset(dev, adc_joystick_cleanup, joy->buffer); 265 - if (error) { 266 - dev_err(dev, "Unable to add action\n"); 267 - return error; 230 + joy->buffer = iio_channel_get_all_cb(dev, adc_joystick_handle, 231 + joy); 232 + if (IS_ERR(joy->buffer)) { 233 + dev_err(dev, "Unable to allocate callback buffer\n"); 234 + return PTR_ERR(joy->buffer); 235 + } 236 + 237 + error = devm_add_action_or_reset(dev, adc_joystick_cleanup, 238 + joy->buffer); 239 + if (error) { 240 + dev_err(dev, "Unable to add action\n"); 241 + return error; 242 + } 268 243 } 269 244 270 245 input_set_drvdata(input, joy);
-3
drivers/input/joystick/adi.c
··· 7 7 * Logitech ADI joystick family driver for Linux 8 8 */ 9 9 10 - /* 11 - */ 12 - 13 10 #include <linux/delay.h> 14 11 #include <linux/kernel.h> 15 12 #include <linux/module.h>
-3
drivers/input/joystick/amijoy.c
··· 7 7 * Driver for Amiga joysticks for Linux/m68k 8 8 */ 9 9 10 - /* 11 - */ 12 - 13 10 #include <linux/types.h> 14 11 #include <linux/errno.h> 15 12 #include <linux/kernel.h>
-3
drivers/input/joystick/analog.c
··· 7 7 * Analog joystick and gamepad driver for Linux 8 8 */ 9 9 10 - /* 11 - */ 12 - 13 10 #include <linux/delay.h> 14 11 #include <linux/kernel.h> 15 12 #include <linux/module.h>
-3
drivers/input/joystick/cobra.c
··· 7 7 * Creative Labs Blaster GamePad Cobra driver for Linux 8 8 */ 9 9 10 - /* 11 - */ 12 - 13 10 #include <linux/kernel.h> 14 11 #include <linux/module.h> 15 12 #include <linux/slab.h>
-3
drivers/input/joystick/db9.c
··· 10 10 * Atari, Amstrad, Commodore, Amiga, Sega, etc. joystick driver for Linux 11 11 */ 12 12 13 - /* 14 - */ 15 - 16 13 #include <linux/kernel.h> 17 14 #include <linux/module.h> 18 15 #include <linux/delay.h>
-3
drivers/input/joystick/gamecon.c
··· 11 11 * Raphael Assenat 12 12 */ 13 13 14 - /* 15 - */ 16 - 17 14 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 18 15 19 16 #include <linux/kernel.h>
-3
drivers/input/joystick/gf2k.c
··· 7 7 * Genius Flight 2000 joystick driver for Linux 8 8 */ 9 9 10 - /* 11 - */ 12 - 13 10 #include <linux/delay.h> 14 11 #include <linux/kernel.h> 15 12 #include <linux/slab.h>
-3
drivers/input/joystick/grip.c
··· 7 7 * Gravis/Kensington GrIP protocol joystick and gamepad driver for Linux 8 8 */ 9 9 10 - /* 11 - */ 12 - 13 10 #include <linux/kernel.h> 14 11 #include <linux/module.h> 15 12 #include <linux/slab.h>
-3
drivers/input/joystick/guillemot.c
··· 7 7 * Guillemot Digital Interface Protocol driver for Linux 8 8 */ 9 9 10 - /* 11 - */ 12 - 13 10 #include <linux/kernel.h> 14 11 #include <linux/slab.h> 15 12 #include <linux/module.h>
-3
drivers/input/joystick/interact.c
··· 10 10 * InterAct digital gamepad/joystick driver for Linux 11 11 */ 12 12 13 - /* 14 - */ 15 - 16 13 #include <linux/kernel.h> 17 14 #include <linux/slab.h> 18 15 #include <linux/module.h>
-3
drivers/input/joystick/joydump.c
··· 8 8 * out of the joystick port into the syslog ... 9 9 */ 10 10 11 - /* 12 - */ 13 - 14 11 #include <linux/module.h> 15 12 #include <linux/gameport.h> 16 13 #include <linux/kernel.h>
-3
drivers/input/joystick/magellan.c
··· 7 7 * Magellan and Space Mouse 6dof controller driver for Linux 8 8 */ 9 9 10 - /* 11 - */ 12 - 13 10 #include <linux/kernel.h> 14 11 #include <linux/module.h> 15 12 #include <linux/slab.h>
-3
drivers/input/joystick/sidewinder.c
··· 7 7 * Microsoft SideWinder joystick family driver for Linux 8 8 */ 9 9 10 - /* 11 - */ 12 - 13 10 #include <linux/delay.h> 14 11 #include <linux/kernel.h> 15 12 #include <linux/module.h>
-3
drivers/input/joystick/spaceball.c
··· 11 11 * SpaceTec SpaceBall 2003/3003/4000 FLX driver for Linux 12 12 */ 13 13 14 - /* 15 - */ 16 - 17 14 #include <linux/kernel.h> 18 15 #include <linux/slab.h> 19 16 #include <linux/module.h>
-3
drivers/input/joystick/spaceorb.c
··· 10 10 * SpaceTec SpaceOrb 360 and Avenger 6dof controller driver for Linux 11 11 */ 12 12 13 - /* 14 - */ 15 - 16 13 #include <linux/kernel.h> 17 14 #include <linux/slab.h> 18 15 #include <linux/module.h>
-3
drivers/input/joystick/stinger.c
··· 8 8 * Gravis Stinger gamepad driver for Linux 9 9 */ 10 10 11 - /* 12 - */ 13 - 14 11 #include <linux/kernel.h> 15 12 #include <linux/module.h> 16 13 #include <linux/slab.h>
-3
drivers/input/joystick/tmdc.c
··· 10 10 * ThrustMaster DirectConnect (BSP) joystick family driver for Linux 11 11 */ 12 12 13 - /* 14 - */ 15 - 16 13 #include <linux/delay.h> 17 14 #include <linux/kernel.h> 18 15 #include <linux/slab.h>
-3
drivers/input/joystick/turbografx.c
··· 10 10 * TurboGraFX parallel port interface driver for Linux. 11 11 */ 12 12 13 - /* 14 - */ 15 - 16 13 #include <linux/kernel.h> 17 14 #include <linux/parport.h> 18 15 #include <linux/input.h>
-3
drivers/input/joystick/twidjoy.c
··· 32 32 * Arndt Schoenewald <arndt@quelltext.com> 33 33 */ 34 34 35 - /* 36 - */ 37 - 38 35 #include <linux/kernel.h> 39 36 #include <linux/module.h> 40 37 #include <linux/slab.h>
-3
drivers/input/joystick/warrior.c
··· 7 7 * Logitech WingMan Warrior joystick driver for Linux 8 8 */ 9 9 10 - /* 11 - */ 12 - 13 10 #include <linux/kernel.h> 14 11 #include <linux/module.h> 15 12 #include <linux/slab.h>
+349 -120
drivers/input/joystick/xpad.c
··· 61 61 * Later changes can be tracked in SCM. 62 62 */ 63 63 64 + #include <linux/bits.h> 64 65 #include <linux/kernel.h> 65 66 #include <linux/input.h> 66 67 #include <linux/rcupdate.h> ··· 81 80 #define MAP_TRIGGERS_TO_BUTTONS (1 << 1) 82 81 #define MAP_STICKS_TO_NULL (1 << 2) 83 82 #define MAP_SELECT_BUTTON (1 << 3) 83 + #define MAP_PADDLES (1 << 4) 84 + #define MAP_PROFILE_BUTTON (1 << 5) 85 + 84 86 #define DANCEPAD_MAP_CONFIG (MAP_DPAD_TO_BUTTONS | \ 85 87 MAP_TRIGGERS_TO_BUTTONS | MAP_STICKS_TO_NULL) 86 88 ··· 92 88 #define XTYPE_XBOX360W 2 93 89 #define XTYPE_XBOXONE 3 94 90 #define XTYPE_UNKNOWN 4 91 + 92 + /* Send power-off packet to xpad360w after holding the mode button for this many 93 + * seconds 94 + */ 95 + #define XPAD360W_POWEROFF_TIMEOUT 5 96 + 97 + #define PKT_XB 0 98 + #define PKT_XBE1 1 99 + #define PKT_XBE2_FW_OLD 2 100 + #define PKT_XBE2_FW_5_EARLY 3 101 + #define PKT_XBE2_FW_5_11 4 95 102 96 103 static bool dpad_to_buttons; 97 104 module_param(dpad_to_buttons, bool, S_IRUGO); ··· 126 111 char *name; 127 112 u8 mapping; 128 113 u8 xtype; 114 + u8 packet_type; 129 115 } xpad_device[] = { 130 116 { 0x0079, 0x18d4, "GPD Win 2 X-Box Controller", 0, XTYPE_XBOX360 }, 117 + { 0x03eb, 0xff01, "Wooting One (Legacy)", 0, XTYPE_XBOX360 }, 118 + { 0x03eb, 0xff02, "Wooting Two (Legacy)", 0, XTYPE_XBOX360 }, 131 119 { 0x044f, 0x0f00, "Thrustmaster Wheel", 0, XTYPE_XBOX }, 132 120 { 0x044f, 0x0f03, "Thrustmaster Wheel", 0, XTYPE_XBOX }, 133 121 { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX }, ··· 146 128 { 0x045e, 0x0291, "Xbox 360 Wireless Receiver (XBOX)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, 147 129 { 0x045e, 0x02d1, "Microsoft X-Box One pad", 0, XTYPE_XBOXONE }, 148 130 { 0x045e, 0x02dd, "Microsoft X-Box One pad (Firmware 2015)", 0, XTYPE_XBOXONE }, 149 - { 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", 0, XTYPE_XBOXONE }, 131 + { 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", MAP_PADDLES, XTYPE_XBOXONE }, 132 + { 0x045e, 0x0b00, "Microsoft X-Box One Elite 2 pad", MAP_PADDLES, XTYPE_XBOXONE }, 150 133 { 0x045e, 0x02ea, "Microsoft X-Box One S pad", 0, XTYPE_XBOXONE }, 151 134 { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, 135 + { 0x045e, 0x0b0a, "Microsoft X-Box Adaptive Controller", MAP_PROFILE_BUTTON, XTYPE_XBOXONE }, 152 136 { 0x045e, 0x0b12, "Microsoft Xbox Series S|X Controller", MAP_SELECT_BUTTON, XTYPE_XBOXONE }, 153 137 { 0x046d, 0xc21d, "Logitech Gamepad F310", 0, XTYPE_XBOX360 }, 154 138 { 0x046d, 0xc21e, "Logitech Gamepad F510", 0, XTYPE_XBOX360 }, ··· 264 244 { 0x0f0d, 0x0063, "Hori Real Arcade Pro Hayabusa (USA) Xbox One", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, 265 245 { 0x0f0d, 0x0067, "HORIPAD ONE", 0, XTYPE_XBOXONE }, 266 246 { 0x0f0d, 0x0078, "Hori Real Arcade Pro V Kai Xbox One", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, 247 + { 0x0f0d, 0x00c5, "Hori Fighting Commander ONE", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, 267 248 { 0x0f30, 0x010b, "Philips Recoil", 0, XTYPE_XBOX }, 268 249 { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX }, 269 250 { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX }, ··· 281 260 { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, 282 261 { 0x1430, 0xf801, "RedOctane Controller", 0, XTYPE_XBOX360 }, 283 262 { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 }, 263 + { 0x146b, 0x0604, "Bigben Interactive DAIJA Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, 284 264 { 0x1532, 0x0037, "Razer Sabertooth", 0, XTYPE_XBOX360 }, 285 265 { 0x1532, 0x0a00, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, 286 266 { 0x1532, 0x0a03, "Razer Wildcat", 0, XTYPE_XBOXONE }, ··· 347 325 { 0x24c6, 0x5502, "Hori Fighting Stick VX Alt", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, 348 326 { 0x24c6, 0x5503, "Hori Fighting Edge", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, 349 327 { 0x24c6, 0x5506, "Hori SOULCALIBUR V Stick", 0, XTYPE_XBOX360 }, 328 + { 0x24c6, 0x5510, "Hori Fighting Commander ONE (Xbox 360/PC Mode)", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, 350 329 { 0x24c6, 0x550d, "Hori GEM Xbox controller", 0, XTYPE_XBOX360 }, 351 330 { 0x24c6, 0x550e, "Hori Real Arcade Pro V Kai 360", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, 352 331 { 0x24c6, 0x551a, "PowerA FUSION Pro Controller", 0, XTYPE_XBOXONE }, ··· 357 334 { 0x24c6, 0x5b03, "Thrustmaster Ferrari 458 Racing Wheel", 0, XTYPE_XBOX360 }, 358 335 { 0x24c6, 0x5d04, "Razer Sabertooth", 0, XTYPE_XBOX360 }, 359 336 { 0x24c6, 0xfafe, "Rock Candy Gamepad for Xbox 360", 0, XTYPE_XBOX360 }, 337 + { 0x2563, 0x058d, "OneXPlayer Gamepad", 0, XTYPE_XBOX360 }, 338 + { 0x2dc8, 0x2000, "8BitDo Pro 2 Wired Controller fox Xbox", 0, XTYPE_XBOXONE }, 339 + { 0x31e3, 0x1100, "Wooting One", 0, XTYPE_XBOX360 }, 340 + { 0x31e3, 0x1200, "Wooting Two", 0, XTYPE_XBOX360 }, 341 + { 0x31e3, 0x1210, "Wooting Lekker", 0, XTYPE_XBOX360 }, 342 + { 0x31e3, 0x1220, "Wooting Two HE", 0, XTYPE_XBOX360 }, 343 + { 0x31e3, 0x1300, "Wooting 60HE (AVR)", 0, XTYPE_XBOX360 }, 344 + { 0x31e3, 0x1310, "Wooting 60HE (ARM)", 0, XTYPE_XBOX360 }, 360 345 { 0x3285, 0x0607, "Nacon GC-100", 0, XTYPE_XBOX360 }, 361 346 { 0x3767, 0x0101, "Fanatec Speedster 3 Forceshock Wheel", 0, XTYPE_XBOX }, 362 347 { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX }, ··· 421 390 -1 422 391 }; 423 392 393 + /* used when the controller has extra paddle buttons */ 394 + static const signed short xpad_btn_paddles[] = { 395 + BTN_TRIGGER_HAPPY5, BTN_TRIGGER_HAPPY6, /* paddle upper right, lower right */ 396 + BTN_TRIGGER_HAPPY7, BTN_TRIGGER_HAPPY8, /* paddle upper left, lower left */ 397 + -1 /* terminating entry */ 398 + }; 399 + 424 400 /* 425 401 * Xbox 360 has a vendor-specific class, so we cannot match it with only 426 402 * USB_INTERFACE_INFO (also specifically refused by USB subsystem), so we ··· 457 419 static const struct usb_device_id xpad_table[] = { 458 420 { USB_INTERFACE_INFO('X', 'B', 0) }, /* X-Box USB-IF not approved class */ 459 421 XPAD_XBOX360_VENDOR(0x0079), /* GPD Win 2 Controller */ 422 + XPAD_XBOX360_VENDOR(0x03eb), /* Wooting Keyboards (Legacy) */ 460 423 XPAD_XBOX360_VENDOR(0x044f), /* Thrustmaster X-Box 360 controllers */ 461 424 XPAD_XBOX360_VENDOR(0x045e), /* Microsoft X-Box 360 controllers */ 462 425 XPAD_XBOXONE_VENDOR(0x045e), /* Microsoft X-Box One controllers */ ··· 468 429 { USB_DEVICE(0x0738, 0x4540) }, /* Mad Catz Beat Pad */ 469 430 XPAD_XBOXONE_VENDOR(0x0738), /* Mad Catz FightStick TE 2 */ 470 431 XPAD_XBOX360_VENDOR(0x07ff), /* Mad Catz GamePad */ 432 + XPAD_XBOX360_VENDOR(0x0c12), /* Zeroplus X-Box 360 controllers */ 471 433 XPAD_XBOX360_VENDOR(0x0e6f), /* 0x0e6f X-Box 360 controllers */ 472 434 XPAD_XBOXONE_VENDOR(0x0e6f), /* 0x0e6f X-Box One controllers */ 473 435 XPAD_XBOX360_VENDOR(0x0f0d), /* Hori Controllers */ ··· 490 450 XPAD_XBOXONE_VENDOR(0x20d6), /* PowerA Controllers */ 491 451 XPAD_XBOX360_VENDOR(0x24c6), /* PowerA Controllers */ 492 452 XPAD_XBOXONE_VENDOR(0x24c6), /* PowerA Controllers */ 453 + XPAD_XBOX360_VENDOR(0x2563), /* OneXPlayer Gamepad */ 454 + XPAD_XBOX360_VENDOR(0x260d), /* Dareu H101 */ 455 + XPAD_XBOXONE_VENDOR(0x2dc8), /* 8BitDo Pro 2 Wired Controller for Xbox */ 493 456 XPAD_XBOXONE_VENDOR(0x2e24), /* Hyperkin Duke X-Box One pad */ 494 457 XPAD_XBOX360_VENDOR(0x2f24), /* GameSir Controllers */ 458 + XPAD_XBOX360_VENDOR(0x31e3), /* Wooting Keyboards */ 495 459 XPAD_XBOX360_VENDOR(0x3285), /* Nacon GC-100 */ 496 460 { } 497 461 }; ··· 517 473 .len = ARRAY_SIZE(_data), \ 518 474 } 519 475 476 + /* 477 + * starting with xbox one, the game input protocol is used 478 + * magic numbers are taken from 479 + * - https://github.com/xpadneo/gip-dissector/blob/main/src/gip-dissector.lua 480 + * - https://github.com/medusalix/xone/blob/master/bus/protocol.c 481 + */ 482 + #define GIP_CMD_ACK 0x01 483 + #define GIP_CMD_IDENTIFY 0x04 484 + #define GIP_CMD_POWER 0x05 485 + #define GIP_CMD_AUTHENTICATE 0x06 486 + #define GIP_CMD_VIRTUAL_KEY 0x07 487 + #define GIP_CMD_RUMBLE 0x09 488 + #define GIP_CMD_LED 0x0a 489 + #define GIP_CMD_FIRMWARE 0x0c 490 + #define GIP_CMD_INPUT 0x20 491 + 492 + #define GIP_SEQ0 0x00 493 + 494 + #define GIP_OPT_ACK 0x10 495 + #define GIP_OPT_INTERNAL 0x20 496 + 497 + /* 498 + * length of the command payload encoded with 499 + * https://en.wikipedia.org/wiki/LEB128 500 + * which is a no-op for N < 128 501 + */ 502 + #define GIP_PL_LEN(N) (N) 503 + 504 + /* 505 + * payload specific defines 506 + */ 507 + #define GIP_PWR_ON 0x00 508 + #define GIP_LED_ON 0x01 509 + 510 + #define GIP_MOTOR_R BIT(0) 511 + #define GIP_MOTOR_L BIT(1) 512 + #define GIP_MOTOR_RT BIT(2) 513 + #define GIP_MOTOR_LT BIT(3) 514 + #define GIP_MOTOR_ALL (GIP_MOTOR_R | GIP_MOTOR_L | GIP_MOTOR_RT | GIP_MOTOR_LT) 520 515 521 516 /* 522 517 * This packet is required for all Xbox One pads with 2015 523 518 * or later firmware installed (or present from the factory). 524 519 */ 525 - static const u8 xboxone_fw2015_init[] = { 526 - 0x05, 0x20, 0x00, 0x01, 0x00 520 + static const u8 xboxone_power_on[] = { 521 + GIP_CMD_POWER, GIP_OPT_INTERNAL, GIP_SEQ0, GIP_PL_LEN(1), GIP_PWR_ON 527 522 }; 528 523 529 524 /* ··· 572 489 * Bluetooth mode. 573 490 */ 574 491 static const u8 xboxone_s_init[] = { 575 - 0x05, 0x20, 0x00, 0x0f, 0x06 492 + GIP_CMD_POWER, GIP_OPT_INTERNAL, GIP_SEQ0, 0x0f, 0x06 493 + }; 494 + 495 + /* 496 + * This packet is required to get additional input data 497 + * from Xbox One Elite Series 2 (0x045e:0x0b00) pads. 498 + * We mostly do this right now to get paddle data 499 + */ 500 + static const u8 extra_input_packet_init[] = { 501 + 0x4d, 0x10, 0x01, 0x02, 0x07, 0x00 576 502 }; 577 503 578 504 /* ··· 589 497 * (0x0e6f:0x0165) to finish initialization and for Hori pads 590 498 * (0x0f0d:0x0067) to make the analog sticks work. 591 499 */ 592 - static const u8 xboxone_hori_init[] = { 593 - 0x01, 0x20, 0x00, 0x09, 0x00, 0x04, 0x20, 0x3a, 594 - 0x00, 0x00, 0x00, 0x80, 0x00 500 + static const u8 xboxone_hori_ack_id[] = { 501 + GIP_CMD_ACK, GIP_OPT_INTERNAL, GIP_SEQ0, GIP_PL_LEN(9), 502 + 0x00, GIP_CMD_IDENTIFY, GIP_OPT_INTERNAL, 0x3a, 0x00, 0x00, 0x00, 0x80, 0x00 595 503 }; 596 504 597 505 /* ··· 599 507 * sending input reports. These pads include: (0x0e6f:0x02ab), 600 508 * (0x0e6f:0x02a4), (0x0e6f:0x02a6). 601 509 */ 602 - static const u8 xboxone_pdp_init1[] = { 603 - 0x0a, 0x20, 0x00, 0x03, 0x00, 0x01, 0x14 510 + static const u8 xboxone_pdp_led_on[] = { 511 + GIP_CMD_LED, GIP_OPT_INTERNAL, GIP_SEQ0, GIP_PL_LEN(3), 0x00, GIP_LED_ON, 0x14 604 512 }; 605 513 606 514 /* ··· 608 516 * sending input reports. These pads include: (0x0e6f:0x02ab), 609 517 * (0x0e6f:0x02a4), (0x0e6f:0x02a6). 610 518 */ 611 - static const u8 xboxone_pdp_init2[] = { 612 - 0x06, 0x20, 0x00, 0x02, 0x01, 0x00 519 + static const u8 xboxone_pdp_auth[] = { 520 + GIP_CMD_AUTHENTICATE, GIP_OPT_INTERNAL, GIP_SEQ0, GIP_PL_LEN(2), 0x01, 0x00 613 521 }; 614 522 615 523 /* ··· 617 525 * sending input reports. One of those pads is (0x24c6:0x543a). 618 526 */ 619 527 static const u8 xboxone_rumblebegin_init[] = { 620 - 0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00, 621 - 0x1D, 0x1D, 0xFF, 0x00, 0x00 528 + GIP_CMD_RUMBLE, 0x00, GIP_SEQ0, GIP_PL_LEN(9), 529 + 0x00, GIP_MOTOR_ALL, 0x00, 0x00, 0x1D, 0x1D, 0xFF, 0x00, 0x00 622 530 }; 623 531 624 532 /* ··· 628 536 * spin up to enough speed to actually vibrate the gamepad. 629 537 */ 630 538 static const u8 xboxone_rumbleend_init[] = { 631 - 0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00, 632 - 0x00, 0x00, 0x00, 0x00, 0x00 539 + GIP_CMD_RUMBLE, 0x00, GIP_SEQ0, GIP_PL_LEN(9), 540 + 0x00, GIP_MOTOR_ALL, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 633 541 }; 634 542 635 543 /* ··· 639 547 * packet is going to be sent. 640 548 */ 641 549 static const struct xboxone_init_packet xboxone_init_packets[] = { 642 - XBOXONE_INIT_PKT(0x0e6f, 0x0165, xboxone_hori_init), 643 - XBOXONE_INIT_PKT(0x0f0d, 0x0067, xboxone_hori_init), 644 - XBOXONE_INIT_PKT(0x0000, 0x0000, xboxone_fw2015_init), 550 + XBOXONE_INIT_PKT(0x0e6f, 0x0165, xboxone_hori_ack_id), 551 + XBOXONE_INIT_PKT(0x0f0d, 0x0067, xboxone_hori_ack_id), 552 + XBOXONE_INIT_PKT(0x0000, 0x0000, xboxone_power_on), 645 553 XBOXONE_INIT_PKT(0x045e, 0x02ea, xboxone_s_init), 646 554 XBOXONE_INIT_PKT(0x045e, 0x0b00, xboxone_s_init), 647 - XBOXONE_INIT_PKT(0x0e6f, 0x0000, xboxone_pdp_init1), 648 - XBOXONE_INIT_PKT(0x0e6f, 0x0000, xboxone_pdp_init2), 555 + XBOXONE_INIT_PKT(0x045e, 0x0b00, extra_input_packet_init), 556 + XBOXONE_INIT_PKT(0x0e6f, 0x0000, xboxone_pdp_led_on), 557 + XBOXONE_INIT_PKT(0x0e6f, 0x0000, xboxone_pdp_auth), 649 558 XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumblebegin_init), 650 559 XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_rumblebegin_init), 651 560 XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_rumblebegin_init), ··· 701 608 702 609 int mapping; /* map d-pad to buttons or to axes */ 703 610 int xtype; /* type of xbox device */ 611 + int packet_type; /* type of the extended packet */ 704 612 int pad_nr; /* the order x360 pads were attached */ 705 613 const char *name; /* name of the device */ 706 614 struct work_struct work; /* init/remove device from callback */ 615 + time64_t mode_btn_down_ts; 707 616 }; 708 617 709 618 static int xpad_init_input(struct usb_xpad *xpad); 710 619 static void xpad_deinit_input(struct usb_xpad *xpad); 711 620 static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num); 621 + static void xpad360w_poweroff_controller(struct usb_xpad *xpad); 712 622 713 623 /* 714 624 * xpad_process_packet ··· 752 656 /* digital pad */ 753 657 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { 754 658 /* dpad as buttons (left, right, up, down) */ 755 - input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & 0x04); 756 - input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & 0x08); 757 - input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & 0x01); 758 - input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & 0x02); 659 + input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & BIT(2)); 660 + input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & BIT(3)); 661 + input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & BIT(0)); 662 + input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & BIT(1)); 759 663 } else { 760 664 input_report_abs(dev, ABS_HAT0X, 761 665 !!(data[2] & 0x08) - !!(data[2] & 0x04)); ··· 764 668 } 765 669 766 670 /* start/back buttons and stick press left/right */ 767 - input_report_key(dev, BTN_START, data[2] & 0x10); 768 - input_report_key(dev, BTN_SELECT, data[2] & 0x20); 769 - input_report_key(dev, BTN_THUMBL, data[2] & 0x40); 770 - input_report_key(dev, BTN_THUMBR, data[2] & 0x80); 671 + input_report_key(dev, BTN_START, data[2] & BIT(4)); 672 + input_report_key(dev, BTN_SELECT, data[2] & BIT(5)); 673 + input_report_key(dev, BTN_THUMBL, data[2] & BIT(6)); 674 + input_report_key(dev, BTN_THUMBR, data[2] & BIT(7)); 771 675 772 676 /* "analog" buttons A, B, X, Y */ 773 677 input_report_key(dev, BTN_A, data[4]); ··· 778 682 /* "analog" buttons black, white */ 779 683 input_report_key(dev, BTN_C, data[8]); 780 684 input_report_key(dev, BTN_Z, data[9]); 685 + 686 + /* Profile button has a value of 0-3, so it is reported as an axis */ 687 + if (xpad->mapping & MAP_PROFILE_BUTTON) 688 + input_report_abs(dev, ABS_PROFILE, data[34]); 781 689 782 690 input_sync(dev); 783 691 } ··· 806 706 /* digital pad */ 807 707 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { 808 708 /* dpad as buttons (left, right, up, down) */ 809 - input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & 0x04); 810 - input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & 0x08); 811 - input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & 0x01); 812 - input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & 0x02); 709 + input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & BIT(2)); 710 + input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & BIT(3)); 711 + input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & BIT(0)); 712 + input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & BIT(1)); 813 713 } 814 714 815 715 /* ··· 827 727 } 828 728 829 729 /* start/back buttons */ 830 - input_report_key(dev, BTN_START, data[2] & 0x10); 831 - input_report_key(dev, BTN_SELECT, data[2] & 0x20); 730 + input_report_key(dev, BTN_START, data[2] & BIT(4)); 731 + input_report_key(dev, BTN_SELECT, data[2] & BIT(5)); 832 732 833 733 /* stick press left/right */ 834 - input_report_key(dev, BTN_THUMBL, data[2] & 0x40); 835 - input_report_key(dev, BTN_THUMBR, data[2] & 0x80); 734 + input_report_key(dev, BTN_THUMBL, data[2] & BIT(6)); 735 + input_report_key(dev, BTN_THUMBR, data[2] & BIT(7)); 836 736 837 737 /* buttons A,B,X,Y,TL,TR and MODE */ 838 - input_report_key(dev, BTN_A, data[3] & 0x10); 839 - input_report_key(dev, BTN_B, data[3] & 0x20); 840 - input_report_key(dev, BTN_X, data[3] & 0x40); 841 - input_report_key(dev, BTN_Y, data[3] & 0x80); 842 - input_report_key(dev, BTN_TL, data[3] & 0x01); 843 - input_report_key(dev, BTN_TR, data[3] & 0x02); 844 - input_report_key(dev, BTN_MODE, data[3] & 0x04); 738 + input_report_key(dev, BTN_A, data[3] & BIT(4)); 739 + input_report_key(dev, BTN_B, data[3] & BIT(5)); 740 + input_report_key(dev, BTN_X, data[3] & BIT(6)); 741 + input_report_key(dev, BTN_Y, data[3] & BIT(7)); 742 + input_report_key(dev, BTN_TL, data[3] & BIT(0)); 743 + input_report_key(dev, BTN_TR, data[3] & BIT(1)); 744 + input_report_key(dev, BTN_MODE, data[3] & BIT(2)); 845 745 846 746 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { 847 747 /* left stick */ ··· 867 767 } 868 768 869 769 input_sync(dev); 770 + 771 + /* XBOX360W controllers can't be turned off without driver assistance */ 772 + if (xpad->xtype == XTYPE_XBOX360W) { 773 + if (xpad->mode_btn_down_ts > 0 && xpad->pad_present && 774 + ((ktime_get_seconds() - xpad->mode_btn_down_ts) >= 775 + XPAD360W_POWEROFF_TIMEOUT)) { 776 + xpad360w_poweroff_controller(xpad); 777 + xpad->mode_btn_down_ts = 0; 778 + return; 779 + } 780 + 781 + /* mode button down/up */ 782 + if (data[3] & BIT(2)) 783 + xpad->mode_btn_down_ts = ktime_get_seconds(); 784 + else 785 + xpad->mode_btn_down_ts = 0; 786 + } 870 787 } 871 788 872 789 static void xpad_presence_work(struct work_struct *work) ··· 963 846 static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) 964 847 { 965 848 struct input_dev *dev = xpad->dev; 849 + bool do_sync = false; 966 850 967 851 /* the xbox button has its own special report */ 968 - if (data[0] == 0X07) { 852 + if (data[0] == GIP_CMD_VIRTUAL_KEY) { 969 853 /* 970 854 * The Xbox One S controller requires these reports to be 971 855 * acked otherwise it continues sending them forever and 972 856 * won't report further mode button events. 973 857 */ 974 - if (data[1] == 0x30) 858 + if (data[1] == (GIP_OPT_ACK | GIP_OPT_INTERNAL)) 975 859 xpadone_ack_mode_report(xpad, data[2]); 976 860 977 - input_report_key(dev, BTN_MODE, data[4] & 0x01); 861 + input_report_key(dev, BTN_MODE, data[4] & GENMASK(1, 0)); 978 862 input_sync(dev); 979 - return; 863 + 864 + do_sync = true; 865 + } else if (data[0] == GIP_CMD_FIRMWARE) { 866 + /* Some packet formats force us to use this separate to poll paddle inputs */ 867 + if (xpad->packet_type == PKT_XBE2_FW_5_11) { 868 + /* Mute paddles if controller is in a custom profile slot 869 + * Checked by looking at the active profile slot to 870 + * verify it's the default slot 871 + */ 872 + if (data[19] != 0) 873 + data[18] = 0; 874 + 875 + /* Elite Series 2 split packet paddle bits */ 876 + input_report_key(dev, BTN_TRIGGER_HAPPY5, data[18] & BIT(0)); 877 + input_report_key(dev, BTN_TRIGGER_HAPPY6, data[18] & BIT(1)); 878 + input_report_key(dev, BTN_TRIGGER_HAPPY7, data[18] & BIT(2)); 879 + input_report_key(dev, BTN_TRIGGER_HAPPY8, data[18] & BIT(3)); 880 + 881 + do_sync = true; 882 + } 883 + } else if (data[0] == GIP_CMD_INPUT) { /* The main valid packet type for inputs */ 884 + /* menu/view buttons */ 885 + input_report_key(dev, BTN_START, data[4] & BIT(2)); 886 + input_report_key(dev, BTN_SELECT, data[4] & BIT(3)); 887 + if (xpad->mapping & MAP_SELECT_BUTTON) 888 + input_report_key(dev, KEY_RECORD, data[22] & BIT(0)); 889 + 890 + /* buttons A,B,X,Y */ 891 + input_report_key(dev, BTN_A, data[4] & BIT(4)); 892 + input_report_key(dev, BTN_B, data[4] & BIT(5)); 893 + input_report_key(dev, BTN_X, data[4] & BIT(6)); 894 + input_report_key(dev, BTN_Y, data[4] & BIT(7)); 895 + 896 + /* digital pad */ 897 + if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { 898 + /* dpad as buttons (left, right, up, down) */ 899 + input_report_key(dev, BTN_TRIGGER_HAPPY1, data[5] & BIT(2)); 900 + input_report_key(dev, BTN_TRIGGER_HAPPY2, data[5] & BIT(3)); 901 + input_report_key(dev, BTN_TRIGGER_HAPPY3, data[5] & BIT(0)); 902 + input_report_key(dev, BTN_TRIGGER_HAPPY4, data[5] & BIT(1)); 903 + } else { 904 + input_report_abs(dev, ABS_HAT0X, 905 + !!(data[5] & 0x08) - !!(data[5] & 0x04)); 906 + input_report_abs(dev, ABS_HAT0Y, 907 + !!(data[5] & 0x02) - !!(data[5] & 0x01)); 908 + } 909 + 910 + /* TL/TR */ 911 + input_report_key(dev, BTN_TL, data[5] & BIT(4)); 912 + input_report_key(dev, BTN_TR, data[5] & BIT(5)); 913 + 914 + /* stick press left/right */ 915 + input_report_key(dev, BTN_THUMBL, data[5] & BIT(6)); 916 + input_report_key(dev, BTN_THUMBR, data[5] & BIT(7)); 917 + 918 + if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { 919 + /* left stick */ 920 + input_report_abs(dev, ABS_X, 921 + (__s16) le16_to_cpup((__le16 *)(data + 10))); 922 + input_report_abs(dev, ABS_Y, 923 + ~(__s16) le16_to_cpup((__le16 *)(data + 12))); 924 + 925 + /* right stick */ 926 + input_report_abs(dev, ABS_RX, 927 + (__s16) le16_to_cpup((__le16 *)(data + 14))); 928 + input_report_abs(dev, ABS_RY, 929 + ~(__s16) le16_to_cpup((__le16 *)(data + 16))); 930 + } 931 + 932 + /* triggers left/right */ 933 + if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { 934 + input_report_key(dev, BTN_TL2, 935 + (__u16) le16_to_cpup((__le16 *)(data + 6))); 936 + input_report_key(dev, BTN_TR2, 937 + (__u16) le16_to_cpup((__le16 *)(data + 8))); 938 + } else { 939 + input_report_abs(dev, ABS_Z, 940 + (__u16) le16_to_cpup((__le16 *)(data + 6))); 941 + input_report_abs(dev, ABS_RZ, 942 + (__u16) le16_to_cpup((__le16 *)(data + 8))); 943 + } 944 + 945 + /* paddle handling */ 946 + /* based on SDL's SDL_hidapi_xboxone.c */ 947 + if (xpad->mapping & MAP_PADDLES) { 948 + if (xpad->packet_type == PKT_XBE1) { 949 + /* Mute paddles if controller has a custom mapping applied. 950 + * Checked by comparing the current mapping 951 + * config against the factory mapping config 952 + */ 953 + if (memcmp(&data[4], &data[18], 2) != 0) 954 + data[32] = 0; 955 + 956 + /* OG Elite Series Controller paddle bits */ 957 + input_report_key(dev, BTN_TRIGGER_HAPPY5, data[32] & BIT(1)); 958 + input_report_key(dev, BTN_TRIGGER_HAPPY6, data[32] & BIT(3)); 959 + input_report_key(dev, BTN_TRIGGER_HAPPY7, data[32] & BIT(0)); 960 + input_report_key(dev, BTN_TRIGGER_HAPPY8, data[32] & BIT(2)); 961 + } else if (xpad->packet_type == PKT_XBE2_FW_OLD) { 962 + /* Mute paddles if controller has a custom mapping applied. 963 + * Checked by comparing the current mapping 964 + * config against the factory mapping config 965 + */ 966 + if (data[19] != 0) 967 + data[18] = 0; 968 + 969 + /* Elite Series 2 4.x firmware paddle bits */ 970 + input_report_key(dev, BTN_TRIGGER_HAPPY5, data[18] & BIT(0)); 971 + input_report_key(dev, BTN_TRIGGER_HAPPY6, data[18] & BIT(1)); 972 + input_report_key(dev, BTN_TRIGGER_HAPPY7, data[18] & BIT(2)); 973 + input_report_key(dev, BTN_TRIGGER_HAPPY8, data[18] & BIT(3)); 974 + } else if (xpad->packet_type == PKT_XBE2_FW_5_EARLY) { 975 + /* Mute paddles if controller has a custom mapping applied. 976 + * Checked by comparing the current mapping 977 + * config against the factory mapping config 978 + */ 979 + if (data[23] != 0) 980 + data[22] = 0; 981 + 982 + /* Elite Series 2 5.x firmware paddle bits 983 + * (before the packet was split) 984 + */ 985 + input_report_key(dev, BTN_TRIGGER_HAPPY5, data[22] & BIT(0)); 986 + input_report_key(dev, BTN_TRIGGER_HAPPY6, data[22] & BIT(1)); 987 + input_report_key(dev, BTN_TRIGGER_HAPPY7, data[22] & BIT(2)); 988 + input_report_key(dev, BTN_TRIGGER_HAPPY8, data[22] & BIT(3)); 989 + } 990 + } 991 + 992 + do_sync = true; 980 993 } 981 - /* check invalid packet */ 982 - else if (data[0] != 0X20) 983 - return; 984 994 985 - /* menu/view buttons */ 986 - input_report_key(dev, BTN_START, data[4] & 0x04); 987 - input_report_key(dev, BTN_SELECT, data[4] & 0x08); 988 - if (xpad->mapping & MAP_SELECT_BUTTON) 989 - input_report_key(dev, KEY_RECORD, data[22] & 0x01); 990 - 991 - /* buttons A,B,X,Y */ 992 - input_report_key(dev, BTN_A, data[4] & 0x10); 993 - input_report_key(dev, BTN_B, data[4] & 0x20); 994 - input_report_key(dev, BTN_X, data[4] & 0x40); 995 - input_report_key(dev, BTN_Y, data[4] & 0x80); 996 - 997 - /* digital pad */ 998 - if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { 999 - /* dpad as buttons (left, right, up, down) */ 1000 - input_report_key(dev, BTN_TRIGGER_HAPPY1, data[5] & 0x04); 1001 - input_report_key(dev, BTN_TRIGGER_HAPPY2, data[5] & 0x08); 1002 - input_report_key(dev, BTN_TRIGGER_HAPPY3, data[5] & 0x01); 1003 - input_report_key(dev, BTN_TRIGGER_HAPPY4, data[5] & 0x02); 1004 - } else { 1005 - input_report_abs(dev, ABS_HAT0X, 1006 - !!(data[5] & 0x08) - !!(data[5] & 0x04)); 1007 - input_report_abs(dev, ABS_HAT0Y, 1008 - !!(data[5] & 0x02) - !!(data[5] & 0x01)); 1009 - } 1010 - 1011 - /* TL/TR */ 1012 - input_report_key(dev, BTN_TL, data[5] & 0x10); 1013 - input_report_key(dev, BTN_TR, data[5] & 0x20); 1014 - 1015 - /* stick press left/right */ 1016 - input_report_key(dev, BTN_THUMBL, data[5] & 0x40); 1017 - input_report_key(dev, BTN_THUMBR, data[5] & 0x80); 1018 - 1019 - if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { 1020 - /* left stick */ 1021 - input_report_abs(dev, ABS_X, 1022 - (__s16) le16_to_cpup((__le16 *)(data + 10))); 1023 - input_report_abs(dev, ABS_Y, 1024 - ~(__s16) le16_to_cpup((__le16 *)(data + 12))); 1025 - 1026 - /* right stick */ 1027 - input_report_abs(dev, ABS_RX, 1028 - (__s16) le16_to_cpup((__le16 *)(data + 14))); 1029 - input_report_abs(dev, ABS_RY, 1030 - ~(__s16) le16_to_cpup((__le16 *)(data + 16))); 1031 - } 1032 - 1033 - /* triggers left/right */ 1034 - if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { 1035 - input_report_key(dev, BTN_TL2, 1036 - (__u16) le16_to_cpup((__le16 *)(data + 6))); 1037 - input_report_key(dev, BTN_TR2, 1038 - (__u16) le16_to_cpup((__le16 *)(data + 8))); 1039 - } else { 1040 - input_report_abs(dev, ABS_Z, 1041 - (__u16) le16_to_cpup((__le16 *)(data + 6))); 1042 - input_report_abs(dev, ABS_RZ, 1043 - (__u16) le16_to_cpup((__le16 *)(data + 8))); 1044 - } 1045 - 1046 - input_sync(dev); 995 + if (do_sync) 996 + input_sync(dev); 1047 997 } 1048 998 1049 999 static void xpad_irq_in(struct urb *urb) ··· 1410 1226 struct xpad_output_packet *packet = 1411 1227 &xpad->out_packets[XPAD_OUT_CMD_IDX]; 1412 1228 static const u8 mode_report_ack[] = { 1413 - 0x01, 0x20, 0x00, 0x09, 0x00, 0x07, 0x20, 0x02, 1414 - 0x00, 0x00, 0x00, 0x00, 0x00 1229 + GIP_CMD_ACK, GIP_OPT_INTERNAL, GIP_SEQ0, GIP_PL_LEN(9), 1230 + 0x00, GIP_CMD_VIRTUAL_KEY, GIP_OPT_INTERNAL, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 1415 1231 }; 1416 1232 1417 1233 spin_lock_irqsave(&xpad->odata_lock, flags); ··· 1489 1305 break; 1490 1306 1491 1307 case XTYPE_XBOXONE: 1492 - packet->data[0] = 0x09; /* activate rumble */ 1308 + packet->data[0] = GIP_CMD_RUMBLE; /* activate rumble */ 1493 1309 packet->data[1] = 0x00; 1494 1310 packet->data[2] = xpad->odata_serial++; 1495 - packet->data[3] = 0x09; 1311 + packet->data[3] = GIP_PL_LEN(9); 1496 1312 packet->data[4] = 0x00; 1497 - packet->data[5] = 0x0F; 1498 - packet->data[6] = 0x00; 1499 - packet->data[7] = 0x00; 1313 + packet->data[5] = GIP_MOTOR_ALL; 1314 + packet->data[6] = 0x00; /* left trigger */ 1315 + packet->data[7] = 0x00; /* right trigger */ 1500 1316 packet->data[8] = strong / 512; /* left actuator */ 1501 1317 packet->data[9] = weak / 512; /* right actuator */ 1502 1318 packet->data[10] = 0xFF; /* on period */ ··· 1806 1622 case ABS_HAT0Y: /* the d-pad (only if dpad is mapped to axes */ 1807 1623 input_set_abs_params(input_dev, abs, -1, 1, 0, 0); 1808 1624 break; 1625 + case ABS_PROFILE: /* 4 value profile button (such as on XAC) */ 1626 + input_set_abs_params(input_dev, abs, 0, 4, 0, 0); 1627 + break; 1809 1628 default: 1810 1629 input_set_abs_params(input_dev, abs, 0, 0, 0, 0); 1811 1630 break; ··· 1880 1693 xpad_btn_pad[i]); 1881 1694 } 1882 1695 1696 + /* set up paddles if the controller has them */ 1697 + if (xpad->mapping & MAP_PADDLES) { 1698 + for (i = 0; xpad_btn_paddles[i] >= 0; i++) 1699 + input_set_capability(input_dev, EV_KEY, xpad_btn_paddles[i]); 1700 + } 1701 + 1883 1702 /* 1884 1703 * This should be a simple else block. However historically 1885 1704 * xbox360w has mapped DPAD to buttons while xbox360 did not. This ··· 1906 1713 for (i = 0; xpad_abs_triggers[i] >= 0; i++) 1907 1714 xpad_set_up_abs(input_dev, xpad_abs_triggers[i]); 1908 1715 } 1716 + 1717 + /* setup profile button as an axis with 4 possible values */ 1718 + if (xpad->mapping & MAP_PROFILE_BUTTON) 1719 + xpad_set_up_abs(input_dev, ABS_PROFILE); 1909 1720 1910 1721 error = xpad_init_ff(xpad); 1911 1722 if (error) ··· 1976 1779 xpad->mapping = xpad_device[i].mapping; 1977 1780 xpad->xtype = xpad_device[i].xtype; 1978 1781 xpad->name = xpad_device[i].name; 1782 + xpad->packet_type = PKT_XB; 1979 1783 INIT_WORK(&xpad->work, xpad_presence_work); 1980 1784 1981 1785 if (xpad->xtype == XTYPE_UNKNOWN) { ··· 2041 1843 xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 2042 1844 2043 1845 usb_set_intfdata(intf, xpad); 1846 + 1847 + /* Packet type detection */ 1848 + if (le16_to_cpu(udev->descriptor.idVendor) == 0x045e) { /* Microsoft controllers */ 1849 + if (le16_to_cpu(udev->descriptor.idProduct) == 0x02e3) { 1850 + /* The original elite controller always uses the oldest 1851 + * type of extended packet 1852 + */ 1853 + xpad->packet_type = PKT_XBE1; 1854 + } else if (le16_to_cpu(udev->descriptor.idProduct) == 0x0b00) { 1855 + /* The elite 2 controller has seen multiple packet 1856 + * revisions. These are tied to specific firmware 1857 + * versions 1858 + */ 1859 + if (le16_to_cpu(udev->descriptor.bcdDevice) < 0x0500) { 1860 + /* This is the format that the Elite 2 used 1861 + * prior to the BLE update 1862 + */ 1863 + xpad->packet_type = PKT_XBE2_FW_OLD; 1864 + } else if (le16_to_cpu(udev->descriptor.bcdDevice) < 1865 + 0x050b) { 1866 + /* This is the format that the Elite 2 used 1867 + * prior to the update that split the packet 1868 + */ 1869 + xpad->packet_type = PKT_XBE2_FW_5_EARLY; 1870 + } else { 1871 + /* The split packet format that was introduced 1872 + * in firmware v5.11 1873 + */ 1874 + xpad->packet_type = PKT_XBE2_FW_5_11; 1875 + } 1876 + } 1877 + } 2044 1878 2045 1879 if (xpad->xtype == XTYPE_XBOX360W) { 2046 1880 /* ··· 2202 1972 .disconnect = xpad_disconnect, 2203 1973 .suspend = xpad_suspend, 2204 1974 .resume = xpad_resume, 2205 - .reset_resume = xpad_resume, 2206 1975 .id_table = xpad_table, 2207 1976 }; 2208 1977
-3
drivers/input/joystick/zhenhua.c
··· 28 28 * coder :-( 29 29 */ 30 30 31 - /* 32 - */ 33 - 34 31 #include <linux/kernel.h> 35 32 #include <linux/module.h> 36 33 #include <linux/slab.h>
+17 -1
drivers/input/keyboard/Kconfig
··· 40 40 config KEYBOARD_ADP5588 41 41 tristate "ADP5588/87 I2C QWERTY Keypad and IO Expander" 42 42 depends on I2C 43 + select GPIOLIB 44 + select GPIOLIB_IRQCHIP 45 + select INPUT_MATRIXKMAP 43 46 help 44 47 Say Y here if you want to use a ADP5588/87 attached to your 45 48 system I2C bus. ··· 189 186 190 187 config KEYBOARD_CLPS711X 191 188 tristate "CLPS711X Keypad support" 192 - depends on OF_GPIO && (ARCH_CLPS711X || COMPILE_TEST) 189 + depends on ARCH_CLPS711X || COMPILE_TEST 193 190 select INPUT_MATRIXKMAP 194 191 help 195 192 Say Y here to enable the matrix keypad on the Cirrus Logic ··· 526 523 527 524 To compile this driver as a module, choose M here; the 528 525 module will be called opencores-kbd. 526 + 527 + config KEYBOARD_PINEPHONE 528 + tristate "Pine64 PinePhone Keyboard" 529 + depends on I2C && REGULATOR 530 + select CRC8 531 + select INPUT_MATRIXKMAP 532 + help 533 + Say Y here to enable support for the keyboard in the Pine64 PinePhone 534 + keyboard case. This driver supports the FLOSS firmware available at 535 + https://megous.com/git/pinephone-keyboard/ 536 + 537 + To compile this driver as a module, choose M here; the 538 + module will be called pinephone-keyboard. 529 539 530 540 config KEYBOARD_PXA27x 531 541 tristate "PXA27x/PXA3xx keypad support"
+1
drivers/input/keyboard/Makefile
··· 52 52 obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o 53 53 obj-$(CONFIG_KEYBOARD_OMAP4) += omap4-keypad.o 54 54 obj-$(CONFIG_KEYBOARD_OPENCORES) += opencores-kbd.o 55 + obj-$(CONFIG_KEYBOARD_PINEPHONE) += pinephone-keyboard.o 55 56 obj-$(CONFIG_KEYBOARD_PMIC8XXX) += pmic8xxx-keypad.o 56 57 obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o 57 58 obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o
+498 -262
drivers/input/keyboard/adp5588-keys.c
··· 8 8 * Copyright (C) 2008-2010 Analog Devices Inc. 9 9 */ 10 10 11 + #include <linux/bits.h> 11 12 #include <linux/delay.h> 12 13 #include <linux/errno.h> 14 + #include <linux/gpio/consumer.h> 13 15 #include <linux/gpio/driver.h> 14 16 #include <linux/i2c.h> 15 17 #include <linux/input.h> 18 + #include <linux/input/matrix_keypad.h> 16 19 #include <linux/interrupt.h> 17 20 #include <linux/irq.h> 18 21 #include <linux/ktime.h> 19 22 #include <linux/module.h> 23 + #include <linux/mod_devicetable.h> 24 + #include <linux/pinctrl/pinconf-generic.h> 20 25 #include <linux/platform_device.h> 21 26 #include <linux/pm.h> 27 + #include <linux/regulator/consumer.h> 22 28 #include <linux/slab.h> 23 29 #include <linux/timekeeping.h> 24 30 25 - #include <linux/platform_data/adp5588.h> 31 + #define DEV_ID 0x00 /* Device ID */ 32 + #define CFG 0x01 /* Configuration Register1 */ 33 + #define INT_STAT 0x02 /* Interrupt Status Register */ 34 + #define KEY_LCK_EC_STAT 0x03 /* Key Lock and Event Counter Register */ 35 + #define KEY_EVENTA 0x04 /* Key Event Register A */ 36 + #define KEY_EVENTB 0x05 /* Key Event Register B */ 37 + #define KEY_EVENTC 0x06 /* Key Event Register C */ 38 + #define KEY_EVENTD 0x07 /* Key Event Register D */ 39 + #define KEY_EVENTE 0x08 /* Key Event Register E */ 40 + #define KEY_EVENTF 0x09 /* Key Event Register F */ 41 + #define KEY_EVENTG 0x0A /* Key Event Register G */ 42 + #define KEY_EVENTH 0x0B /* Key Event Register H */ 43 + #define KEY_EVENTI 0x0C /* Key Event Register I */ 44 + #define KEY_EVENTJ 0x0D /* Key Event Register J */ 45 + #define KP_LCK_TMR 0x0E /* Keypad Lock1 to Lock2 Timer */ 46 + #define UNLOCK1 0x0F /* Unlock Key1 */ 47 + #define UNLOCK2 0x10 /* Unlock Key2 */ 48 + #define GPIO_INT_STAT1 0x11 /* GPIO Interrupt Status */ 49 + #define GPIO_INT_STAT2 0x12 /* GPIO Interrupt Status */ 50 + #define GPIO_INT_STAT3 0x13 /* GPIO Interrupt Status */ 51 + #define GPIO_DAT_STAT1 0x14 /* GPIO Data Status, Read twice to clear */ 52 + #define GPIO_DAT_STAT2 0x15 /* GPIO Data Status, Read twice to clear */ 53 + #define GPIO_DAT_STAT3 0x16 /* GPIO Data Status, Read twice to clear */ 54 + #define GPIO_DAT_OUT1 0x17 /* GPIO DATA OUT */ 55 + #define GPIO_DAT_OUT2 0x18 /* GPIO DATA OUT */ 56 + #define GPIO_DAT_OUT3 0x19 /* GPIO DATA OUT */ 57 + #define GPIO_INT_EN1 0x1A /* GPIO Interrupt Enable */ 58 + #define GPIO_INT_EN2 0x1B /* GPIO Interrupt Enable */ 59 + #define GPIO_INT_EN3 0x1C /* GPIO Interrupt Enable */ 60 + #define KP_GPIO1 0x1D /* Keypad or GPIO Selection */ 61 + #define KP_GPIO2 0x1E /* Keypad or GPIO Selection */ 62 + #define KP_GPIO3 0x1F /* Keypad or GPIO Selection */ 63 + #define GPI_EM1 0x20 /* GPI Event Mode 1 */ 64 + #define GPI_EM2 0x21 /* GPI Event Mode 2 */ 65 + #define GPI_EM3 0x22 /* GPI Event Mode 3 */ 66 + #define GPIO_DIR1 0x23 /* GPIO Data Direction */ 67 + #define GPIO_DIR2 0x24 /* GPIO Data Direction */ 68 + #define GPIO_DIR3 0x25 /* GPIO Data Direction */ 69 + #define GPIO_INT_LVL1 0x26 /* GPIO Edge/Level Detect */ 70 + #define GPIO_INT_LVL2 0x27 /* GPIO Edge/Level Detect */ 71 + #define GPIO_INT_LVL3 0x28 /* GPIO Edge/Level Detect */ 72 + #define DEBOUNCE_DIS1 0x29 /* Debounce Disable */ 73 + #define DEBOUNCE_DIS2 0x2A /* Debounce Disable */ 74 + #define DEBOUNCE_DIS3 0x2B /* Debounce Disable */ 75 + #define GPIO_PULL1 0x2C /* GPIO Pull Disable */ 76 + #define GPIO_PULL2 0x2D /* GPIO Pull Disable */ 77 + #define GPIO_PULL3 0x2E /* GPIO Pull Disable */ 78 + #define CMP_CFG_STAT 0x30 /* Comparator Configuration and Status Register */ 79 + #define CMP_CONFG_SENS1 0x31 /* Sensor1 Comparator Configuration Register */ 80 + #define CMP_CONFG_SENS2 0x32 /* L2 Light Sensor Reference Level, Output Falling for Sensor 1 */ 81 + #define CMP1_LVL2_TRIP 0x33 /* L2 Light Sensor Hysteresis (Active when Output Rising) for Sensor 1 */ 82 + #define CMP1_LVL2_HYS 0x34 /* L3 Light Sensor Reference Level, Output Falling For Sensor 1 */ 83 + #define CMP1_LVL3_TRIP 0x35 /* L3 Light Sensor Hysteresis (Active when Output Rising) For Sensor 1 */ 84 + #define CMP1_LVL3_HYS 0x36 /* Sensor 2 Comparator Configuration Register */ 85 + #define CMP2_LVL2_TRIP 0x37 /* L2 Light Sensor Reference Level, Output Falling for Sensor 2 */ 86 + #define CMP2_LVL2_HYS 0x38 /* L2 Light Sensor Hysteresis (Active when Output Rising) for Sensor 2 */ 87 + #define CMP2_LVL3_TRIP 0x39 /* L3 Light Sensor Reference Level, Output Falling For Sensor 2 */ 88 + #define CMP2_LVL3_HYS 0x3A /* L3 Light Sensor Hysteresis (Active when Output Rising) For Sensor 2 */ 89 + #define CMP1_ADC_DAT_R1 0x3B /* Comparator 1 ADC data Register1 */ 90 + #define CMP1_ADC_DAT_R2 0x3C /* Comparator 1 ADC data Register2 */ 91 + #define CMP2_ADC_DAT_R1 0x3D /* Comparator 2 ADC data Register1 */ 92 + #define CMP2_ADC_DAT_R2 0x3E /* Comparator 2 ADC data Register2 */ 93 + 94 + #define ADP5588_DEVICE_ID_MASK 0xF 95 + 96 + /* Configuration Register1 */ 97 + #define ADP5588_AUTO_INC BIT(7) 98 + #define ADP5588_GPIEM_CFG BIT(6) 99 + #define ADP5588_OVR_FLOW_M BIT(5) 100 + #define ADP5588_INT_CFG BIT(4) 101 + #define ADP5588_OVR_FLOW_IEN BIT(3) 102 + #define ADP5588_K_LCK_IM BIT(2) 103 + #define ADP5588_GPI_IEN BIT(1) 104 + #define ADP5588_KE_IEN BIT(0) 105 + 106 + /* Interrupt Status Register */ 107 + #define ADP5588_CMP2_INT BIT(5) 108 + #define ADP5588_CMP1_INT BIT(4) 109 + #define ADP5588_OVR_FLOW_INT BIT(3) 110 + #define ADP5588_K_LCK_INT BIT(2) 111 + #define ADP5588_GPI_INT BIT(1) 112 + #define ADP5588_KE_INT BIT(0) 113 + 114 + /* Key Lock and Event Counter Register */ 115 + #define ADP5588_K_LCK_EN BIT(6) 116 + #define ADP5588_LCK21 0x30 117 + #define ADP5588_KEC GENMASK(3, 0) 118 + 119 + #define ADP5588_MAXGPIO 18 120 + #define ADP5588_BANK(offs) ((offs) >> 3) 121 + #define ADP5588_BIT(offs) (1u << ((offs) & 0x7)) 122 + 123 + /* Put one of these structures in i2c_board_info platform_data */ 124 + 125 + /* 126 + * 128 so it fits matrix-keymap maximum number of keys when the full 127 + * 10cols * 8rows are used. 128 + */ 129 + #define ADP5588_KEYMAPSIZE 128 130 + 131 + #define GPI_PIN_ROW0 97 132 + #define GPI_PIN_ROW1 98 133 + #define GPI_PIN_ROW2 99 134 + #define GPI_PIN_ROW3 100 135 + #define GPI_PIN_ROW4 101 136 + #define GPI_PIN_ROW5 102 137 + #define GPI_PIN_ROW6 103 138 + #define GPI_PIN_ROW7 104 139 + #define GPI_PIN_COL0 105 140 + #define GPI_PIN_COL1 106 141 + #define GPI_PIN_COL2 107 142 + #define GPI_PIN_COL3 108 143 + #define GPI_PIN_COL4 109 144 + #define GPI_PIN_COL5 110 145 + #define GPI_PIN_COL6 111 146 + #define GPI_PIN_COL7 112 147 + #define GPI_PIN_COL8 113 148 + #define GPI_PIN_COL9 114 149 + 150 + #define GPI_PIN_ROW_BASE GPI_PIN_ROW0 151 + #define GPI_PIN_ROW_END GPI_PIN_ROW7 152 + #define GPI_PIN_COL_BASE GPI_PIN_COL0 153 + #define GPI_PIN_COL_END GPI_PIN_COL9 154 + 155 + #define GPI_PIN_BASE GPI_PIN_ROW_BASE 156 + #define GPI_PIN_END GPI_PIN_COL_END 157 + 158 + #define ADP5588_ROWS_MAX (GPI_PIN_ROW7 - GPI_PIN_ROW0 + 1) 159 + #define ADP5588_COLS_MAX (GPI_PIN_COL9 - GPI_PIN_COL0 + 1) 160 + 161 + #define ADP5588_GPIMAPSIZE_MAX (GPI_PIN_END - GPI_PIN_BASE + 1) 26 162 27 163 /* Key Event Register xy */ 28 - #define KEY_EV_PRESSED (1 << 7) 29 - #define KEY_EV_MASK (0x7F) 164 + #define KEY_EV_PRESSED BIT(7) 165 + #define KEY_EV_MASK GENMASK(6, 0) 30 166 31 - #define KP_SEL(x) (0xFFFF >> (16 - x)) /* 2^x-1 */ 167 + #define KP_SEL(x) (BIT(x) - 1) /* 2^x-1 */ 32 168 33 169 #define KEYP_MAX_EVENT 10 34 170 ··· 176 40 #define WA_DELAYED_READOUT_REVID(rev) ((rev) < 4) 177 41 #define WA_DELAYED_READOUT_TIME 25 178 42 43 + #define ADP5588_INVALID_HWIRQ (~0UL) 44 + 179 45 struct adp5588_kpad { 180 46 struct i2c_client *client; 181 47 struct input_dev *input; 182 48 ktime_t irq_time; 183 49 unsigned long delay; 50 + u32 row_shift; 51 + u32 rows; 52 + u32 cols; 53 + u32 unlock_keys[2]; 54 + int nkeys_unlock; 184 55 unsigned short keycode[ADP5588_KEYMAPSIZE]; 185 - const struct adp5588_gpi_map *gpimap; 186 - unsigned short gpimapsize; 187 - #ifdef CONFIG_GPIOLIB 188 56 unsigned char gpiomap[ADP5588_MAXGPIO]; 189 57 struct gpio_chip gc; 190 58 struct mutex gpio_lock; /* Protect cached dir, dat_out */ 191 59 u8 dat_out[3]; 192 60 u8 dir[3]; 193 - #endif 61 + u8 int_en[3]; 62 + u8 irq_mask[3]; 63 + u8 pull_dis[3]; 194 64 }; 195 65 196 66 static int adp5588_read(struct i2c_client *client, u8 reg) ··· 214 72 return i2c_smbus_write_byte_data(client, reg, val); 215 73 } 216 74 217 - #ifdef CONFIG_GPIOLIB 218 - static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned off) 75 + static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned int off) 219 76 { 220 77 struct adp5588_kpad *kpad = gpiochip_get_data(chip); 221 78 unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]); ··· 234 93 } 235 94 236 95 static void adp5588_gpio_set_value(struct gpio_chip *chip, 237 - unsigned off, int val) 96 + unsigned int off, int val) 238 97 { 239 98 struct adp5588_kpad *kpad = gpiochip_get_data(chip); 240 99 unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]); ··· 247 106 else 248 107 kpad->dat_out[bank] &= ~bit; 249 108 250 - adp5588_write(kpad->client, GPIO_DAT_OUT1 + bank, 251 - kpad->dat_out[bank]); 109 + adp5588_write(kpad->client, GPIO_DAT_OUT1 + bank, kpad->dat_out[bank]); 252 110 253 111 mutex_unlock(&kpad->gpio_lock); 254 112 } 255 113 256 - static int adp5588_gpio_direction_input(struct gpio_chip *chip, unsigned off) 114 + static int adp5588_gpio_set_config(struct gpio_chip *chip, unsigned int off, 115 + unsigned long config) 116 + { 117 + struct adp5588_kpad *kpad = gpiochip_get_data(chip); 118 + unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]); 119 + unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]); 120 + bool pull_disable; 121 + int ret; 122 + 123 + switch (pinconf_to_config_param(config)) { 124 + case PIN_CONFIG_BIAS_PULL_UP: 125 + pull_disable = false; 126 + break; 127 + case PIN_CONFIG_BIAS_DISABLE: 128 + pull_disable = true; 129 + break; 130 + default: 131 + return -ENOTSUPP; 132 + } 133 + 134 + mutex_lock(&kpad->gpio_lock); 135 + 136 + if (pull_disable) 137 + kpad->pull_dis[bank] |= bit; 138 + else 139 + kpad->pull_dis[bank] &= bit; 140 + 141 + ret = adp5588_write(kpad->client, GPIO_PULL1 + bank, 142 + kpad->pull_dis[bank]); 143 + 144 + mutex_unlock(&kpad->gpio_lock); 145 + 146 + return ret; 147 + } 148 + 149 + static int adp5588_gpio_direction_input(struct gpio_chip *chip, unsigned int off) 257 150 { 258 151 struct adp5588_kpad *kpad = gpiochip_get_data(chip); 259 152 unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]); ··· 305 130 } 306 131 307 132 static int adp5588_gpio_direction_output(struct gpio_chip *chip, 308 - unsigned off, int val) 133 + unsigned int off, int val) 309 134 { 310 135 struct adp5588_kpad *kpad = gpiochip_get_data(chip); 311 136 unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]); ··· 322 147 kpad->dat_out[bank] &= ~bit; 323 148 324 149 ret = adp5588_write(kpad->client, GPIO_DAT_OUT1 + bank, 325 - kpad->dat_out[bank]); 326 - ret |= adp5588_write(kpad->client, GPIO_DIR1 + bank, 327 - kpad->dir[bank]); 150 + kpad->dat_out[bank]); 151 + if (ret) 152 + goto out_unlock; 328 153 154 + ret = adp5588_write(kpad->client, GPIO_DIR1 + bank, kpad->dir[bank]); 155 + 156 + out_unlock: 329 157 mutex_unlock(&kpad->gpio_lock); 330 158 331 159 return ret; 332 160 } 333 161 334 - static int adp5588_build_gpiomap(struct adp5588_kpad *kpad, 335 - const struct adp5588_kpad_platform_data *pdata) 162 + static int adp5588_build_gpiomap(struct adp5588_kpad *kpad) 336 163 { 337 164 bool pin_used[ADP5588_MAXGPIO]; 338 165 int n_unused = 0; ··· 342 165 343 166 memset(pin_used, 0, sizeof(pin_used)); 344 167 345 - for (i = 0; i < pdata->rows; i++) 168 + for (i = 0; i < kpad->rows; i++) 346 169 pin_used[i] = true; 347 170 348 - for (i = 0; i < pdata->cols; i++) 171 + for (i = 0; i < kpad->cols; i++) 349 172 pin_used[i + GPI_PIN_COL_BASE - GPI_PIN_BASE] = true; 350 - 351 - for (i = 0; i < kpad->gpimapsize; i++) 352 - pin_used[kpad->gpimap[i].pin - GPI_PIN_BASE] = true; 353 173 354 174 for (i = 0; i < ADP5588_MAXGPIO; i++) 355 175 if (!pin_used[i]) ··· 355 181 return n_unused; 356 182 } 357 183 358 - static void adp5588_gpio_do_teardown(void *_kpad) 184 + static void adp5588_irq_bus_lock(struct irq_data *d) 359 185 { 360 - struct adp5588_kpad *kpad = _kpad; 361 - struct device *dev = &kpad->client->dev; 362 - const struct adp5588_kpad_platform_data *pdata = dev_get_platdata(dev); 363 - const struct adp5588_gpio_platform_data *gpio_data = pdata->gpio_data; 364 - int error; 186 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 187 + struct adp5588_kpad *kpad = gpiochip_get_data(gc); 365 188 366 - error = gpio_data->teardown(kpad->client, 367 - kpad->gc.base, kpad->gc.ngpio, 368 - gpio_data->context); 369 - if (error) 370 - dev_warn(&kpad->client->dev, "teardown failed %d\n", error); 189 + mutex_lock(&kpad->gpio_lock); 371 190 } 191 + 192 + static void adp5588_irq_bus_sync_unlock(struct irq_data *d) 193 + { 194 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 195 + struct adp5588_kpad *kpad = gpiochip_get_data(gc); 196 + int i; 197 + 198 + for (i = 0; i <= ADP5588_BANK(ADP5588_MAXGPIO); i++) { 199 + if (kpad->int_en[i] ^ kpad->irq_mask[i]) { 200 + kpad->int_en[i] = kpad->irq_mask[i]; 201 + adp5588_write(kpad->client, GPI_EM1 + i, kpad->int_en[i]); 202 + } 203 + } 204 + 205 + mutex_unlock(&kpad->gpio_lock); 206 + } 207 + 208 + static void adp5588_irq_mask(struct irq_data *d) 209 + { 210 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 211 + struct adp5588_kpad *kpad = gpiochip_get_data(gc); 212 + irq_hw_number_t hwirq = irqd_to_hwirq(d); 213 + unsigned long real_irq = kpad->gpiomap[hwirq]; 214 + 215 + kpad->irq_mask[ADP5588_BANK(real_irq)] &= ~ADP5588_BIT(real_irq); 216 + gpiochip_disable_irq(gc, hwirq); 217 + } 218 + 219 + static void adp5588_irq_unmask(struct irq_data *d) 220 + { 221 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 222 + struct adp5588_kpad *kpad = gpiochip_get_data(gc); 223 + irq_hw_number_t hwirq = irqd_to_hwirq(d); 224 + unsigned long real_irq = kpad->gpiomap[hwirq]; 225 + 226 + gpiochip_enable_irq(gc, hwirq); 227 + kpad->irq_mask[ADP5588_BANK(real_irq)] |= ADP5588_BIT(real_irq); 228 + } 229 + 230 + static int adp5588_irq_set_type(struct irq_data *d, unsigned int type) 231 + { 232 + if (!(type & IRQ_TYPE_EDGE_BOTH)) 233 + return -EINVAL; 234 + 235 + irq_set_handler_locked(d, handle_edge_irq); 236 + 237 + return 0; 238 + } 239 + 240 + static const struct irq_chip adp5588_irq_chip = { 241 + .name = "adp5588", 242 + .irq_mask = adp5588_irq_mask, 243 + .irq_unmask = adp5588_irq_unmask, 244 + .irq_bus_lock = adp5588_irq_bus_lock, 245 + .irq_bus_sync_unlock = adp5588_irq_bus_sync_unlock, 246 + .irq_set_type = adp5588_irq_set_type, 247 + .flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE, 248 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 249 + }; 372 250 373 251 static int adp5588_gpio_add(struct adp5588_kpad *kpad) 374 252 { 375 253 struct device *dev = &kpad->client->dev; 376 - const struct adp5588_kpad_platform_data *pdata = dev_get_platdata(dev); 377 - const struct adp5588_gpio_platform_data *gpio_data = pdata->gpio_data; 254 + struct gpio_irq_chip *girq; 378 255 int i, error; 379 256 380 - if (!gpio_data) 381 - return 0; 382 - 383 - kpad->gc.ngpio = adp5588_build_gpiomap(kpad, pdata); 257 + kpad->gc.ngpio = adp5588_build_gpiomap(kpad); 384 258 if (kpad->gc.ngpio == 0) { 385 259 dev_info(dev, "No unused gpios left to export\n"); 386 260 return 0; 387 261 } 388 262 263 + kpad->gc.parent = &kpad->client->dev; 389 264 kpad->gc.direction_input = adp5588_gpio_direction_input; 390 265 kpad->gc.direction_output = adp5588_gpio_direction_output; 391 266 kpad->gc.get = adp5588_gpio_get_value; 392 267 kpad->gc.set = adp5588_gpio_set_value; 268 + kpad->gc.set_config = adp5588_gpio_set_config; 393 269 kpad->gc.can_sleep = 1; 394 270 395 - kpad->gc.base = gpio_data->gpio_start; 271 + kpad->gc.base = -1; 396 272 kpad->gc.label = kpad->client->name; 397 273 kpad->gc.owner = THIS_MODULE; 398 - kpad->gc.names = gpio_data->names; 274 + 275 + girq = &kpad->gc.irq; 276 + gpio_irq_chip_set_chip(girq, &adp5588_irq_chip); 277 + girq->handler = handle_bad_irq; 278 + girq->threaded = true; 399 279 400 280 mutex_init(&kpad->gpio_lock); 401 281 ··· 463 235 kpad->dat_out[i] = adp5588_read(kpad->client, 464 236 GPIO_DAT_OUT1 + i); 465 237 kpad->dir[i] = adp5588_read(kpad->client, GPIO_DIR1 + i); 466 - } 467 - 468 - if (gpio_data->setup) { 469 - error = gpio_data->setup(kpad->client, 470 - kpad->gc.base, kpad->gc.ngpio, 471 - gpio_data->context); 472 - if (error) 473 - dev_warn(dev, "setup failed: %d\n", error); 474 - } 475 - 476 - if (gpio_data->teardown) { 477 - error = devm_add_action(dev, adp5588_gpio_do_teardown, kpad); 478 - if (error) 479 - dev_warn(dev, "failed to schedule teardown: %d\n", 480 - error); 238 + kpad->pull_dis[i] = adp5588_read(kpad->client, GPIO_PULL1 + i); 481 239 } 482 240 483 241 return 0; 484 242 } 485 243 486 - #else 487 - static inline int adp5588_gpio_add(struct adp5588_kpad *kpad) 244 + static unsigned long adp5588_gpiomap_get_hwirq(struct device *dev, 245 + const u8 *map, unsigned int gpio, 246 + unsigned int ngpios) 488 247 { 489 - return 0; 248 + unsigned int hwirq; 249 + 250 + for (hwirq = 0; hwirq < ngpios; hwirq++) 251 + if (map[hwirq] == gpio) 252 + return hwirq; 253 + 254 + /* should never happen */ 255 + dev_warn_ratelimited(dev, "could not find the hwirq for gpio(%u)\n", gpio); 256 + 257 + return ADP5588_INVALID_HWIRQ; 490 258 } 491 - #endif 259 + 260 + static void adp5588_gpio_irq_handle(struct adp5588_kpad *kpad, int key_val, 261 + int key_press) 262 + { 263 + unsigned int irq, gpio = key_val - GPI_PIN_BASE, irq_type; 264 + struct i2c_client *client = kpad->client; 265 + struct irq_data *irqd; 266 + unsigned long hwirq; 267 + 268 + hwirq = adp5588_gpiomap_get_hwirq(&client->dev, kpad->gpiomap, 269 + gpio, kpad->gc.ngpio); 270 + if (hwirq == ADP5588_INVALID_HWIRQ) { 271 + dev_err(&client->dev, "Could not get hwirq for key(%u)\n", key_val); 272 + return; 273 + } 274 + 275 + irq = irq_find_mapping(kpad->gc.irq.domain, hwirq); 276 + if (!irq) 277 + return; 278 + 279 + irqd = irq_get_irq_data(irq); 280 + if (!irqd) { 281 + dev_err(&client->dev, "Could not get irq(%u) data\n", irq); 282 + return; 283 + } 284 + 285 + irq_type = irqd_get_trigger_type(irqd); 286 + 287 + /* 288 + * Default is active low which means key_press is asserted on 289 + * the falling edge. 290 + */ 291 + if ((irq_type & IRQ_TYPE_EDGE_RISING && !key_press) || 292 + (irq_type & IRQ_TYPE_EDGE_FALLING && key_press)) 293 + handle_nested_irq(irq); 294 + } 492 295 493 296 static void adp5588_report_events(struct adp5588_kpad *kpad, int ev_cnt) 494 297 { 495 - int i, j; 298 + int i; 496 299 497 300 for (i = 0; i < ev_cnt; i++) { 498 - int key = adp5588_read(kpad->client, Key_EVENTA + i); 301 + int key = adp5588_read(kpad->client, KEY_EVENTA + i); 499 302 int key_val = key & KEY_EV_MASK; 303 + int key_press = key & KEY_EV_PRESSED; 500 304 501 305 if (key_val >= GPI_PIN_BASE && key_val <= GPI_PIN_END) { 502 - for (j = 0; j < kpad->gpimapsize; j++) { 503 - if (key_val == kpad->gpimap[j].pin) { 504 - input_report_switch(kpad->input, 505 - kpad->gpimap[j].sw_evt, 506 - key & KEY_EV_PRESSED); 507 - break; 508 - } 509 - } 306 + /* gpio line used as IRQ source */ 307 + adp5588_gpio_irq_handle(kpad, key_val, key_press); 510 308 } else { 309 + int row = (key_val - 1) / ADP5588_COLS_MAX; 310 + int col = (key_val - 1) % ADP5588_COLS_MAX; 311 + int code = MATRIX_SCAN_CODE(row, col, kpad->row_shift); 312 + 313 + dev_dbg_ratelimited(&kpad->client->dev, 314 + "report key(%d) r(%d) c(%d) code(%d)\n", 315 + key_val, row, col, kpad->keycode[code]); 316 + 511 317 input_report_key(kpad->input, 512 - kpad->keycode[key_val - 1], 513 - key & KEY_EV_PRESSED); 318 + kpad->keycode[code], key_press); 514 319 } 515 320 } 516 321 } ··· 596 335 return IRQ_HANDLED; 597 336 } 598 337 599 - static int adp5588_setup(struct i2c_client *client) 338 + static int adp5588_setup(struct adp5588_kpad *kpad) 600 339 { 601 - const struct adp5588_kpad_platform_data *pdata = 602 - dev_get_platdata(&client->dev); 603 - const struct adp5588_gpio_platform_data *gpio_data = pdata->gpio_data; 340 + struct i2c_client *client = kpad->client; 604 341 int i, ret; 605 - unsigned char evt_mode1 = 0, evt_mode2 = 0, evt_mode3 = 0; 606 342 607 - ret = adp5588_write(client, KP_GPIO1, KP_SEL(pdata->rows)); 608 - ret |= adp5588_write(client, KP_GPIO2, KP_SEL(pdata->cols) & 0xFF); 609 - ret |= adp5588_write(client, KP_GPIO3, KP_SEL(pdata->cols) >> 8); 610 - 611 - if (pdata->en_keylock) { 612 - ret |= adp5588_write(client, UNLOCK1, pdata->unlock_key1); 613 - ret |= adp5588_write(client, UNLOCK2, pdata->unlock_key2); 614 - ret |= adp5588_write(client, KEY_LCK_EC_STAT, ADP5588_K_LCK_EN); 615 - } 616 - 617 - for (i = 0; i < KEYP_MAX_EVENT; i++) 618 - ret |= adp5588_read(client, Key_EVENTA); 619 - 620 - for (i = 0; i < pdata->gpimapsize; i++) { 621 - unsigned short pin = pdata->gpimap[i].pin; 622 - 623 - if (pin <= GPI_PIN_ROW_END) { 624 - evt_mode1 |= (1 << (pin - GPI_PIN_ROW_BASE)); 625 - } else { 626 - evt_mode2 |= ((1 << (pin - GPI_PIN_COL_BASE)) & 0xFF); 627 - evt_mode3 |= ((1 << (pin - GPI_PIN_COL_BASE)) >> 8); 628 - } 629 - } 630 - 631 - if (pdata->gpimapsize) { 632 - ret |= adp5588_write(client, GPI_EM1, evt_mode1); 633 - ret |= adp5588_write(client, GPI_EM2, evt_mode2); 634 - ret |= adp5588_write(client, GPI_EM3, evt_mode3); 635 - } 636 - 637 - if (gpio_data) { 638 - for (i = 0; i <= ADP5588_BANK(ADP5588_MAXGPIO); i++) { 639 - int pull_mask = gpio_data->pullup_dis_mask; 640 - 641 - ret |= adp5588_write(client, GPIO_PULL1 + i, 642 - (pull_mask >> (8 * i)) & 0xFF); 643 - } 644 - } 645 - 646 - ret |= adp5588_write(client, INT_STAT, 647 - ADP5588_CMP2_INT | ADP5588_CMP1_INT | 648 - ADP5588_OVR_FLOW_INT | ADP5588_K_LCK_INT | 649 - ADP5588_GPI_INT | ADP5588_KE_INT); /* Status is W1C */ 650 - 651 - ret |= adp5588_write(client, CFG, ADP5588_INT_CFG | 652 - ADP5588_OVR_FLOW_IEN | 653 - ADP5588_KE_IEN); 654 - 655 - if (ret < 0) { 656 - dev_err(&client->dev, "Write Error\n"); 343 + ret = adp5588_write(client, KP_GPIO1, KP_SEL(kpad->rows)); 344 + if (ret) 657 345 return ret; 346 + 347 + ret = adp5588_write(client, KP_GPIO2, KP_SEL(kpad->cols) & 0xFF); 348 + if (ret) 349 + return ret; 350 + 351 + ret = adp5588_write(client, KP_GPIO3, KP_SEL(kpad->cols) >> 8); 352 + if (ret) 353 + return ret; 354 + 355 + for (i = 0; i < kpad->nkeys_unlock; i++) { 356 + ret = adp5588_write(client, UNLOCK1 + i, kpad->unlock_keys[i]); 357 + if (ret) 358 + return ret; 359 + } 360 + 361 + if (kpad->nkeys_unlock) { 362 + ret = adp5588_write(client, KEY_LCK_EC_STAT, ADP5588_K_LCK_EN); 363 + if (ret) 364 + return ret; 365 + } 366 + 367 + for (i = 0; i < KEYP_MAX_EVENT; i++) { 368 + ret = adp5588_read(client, KEY_EVENTA); 369 + if (ret) 370 + return ret; 371 + } 372 + 373 + ret = adp5588_write(client, INT_STAT, 374 + ADP5588_CMP2_INT | ADP5588_CMP1_INT | 375 + ADP5588_OVR_FLOW_INT | ADP5588_K_LCK_INT | 376 + ADP5588_GPI_INT | ADP5588_KE_INT); /* Status is W1C */ 377 + if (ret) 378 + return ret; 379 + 380 + return adp5588_write(client, CFG, ADP5588_INT_CFG | 381 + ADP5588_OVR_FLOW_IEN | ADP5588_KE_IEN); 382 + } 383 + 384 + static int adp5588_fw_parse(struct adp5588_kpad *kpad) 385 + { 386 + struct i2c_client *client = kpad->client; 387 + int ret, i; 388 + 389 + ret = matrix_keypad_parse_properties(&client->dev, &kpad->rows, 390 + &kpad->cols); 391 + if (ret) 392 + return ret; 393 + 394 + if (kpad->rows > ADP5588_ROWS_MAX || kpad->cols > ADP5588_COLS_MAX) { 395 + dev_err(&client->dev, "Invalid nr of rows(%u) or cols(%u)\n", 396 + kpad->rows, kpad->cols); 397 + return -EINVAL; 398 + } 399 + 400 + ret = matrix_keypad_build_keymap(NULL, NULL, kpad->rows, kpad->cols, 401 + kpad->keycode, kpad->input); 402 + if (ret) 403 + return ret; 404 + 405 + kpad->row_shift = get_count_order(kpad->cols); 406 + 407 + if (device_property_read_bool(&client->dev, "autorepeat")) 408 + __set_bit(EV_REP, kpad->input->evbit); 409 + 410 + kpad->nkeys_unlock = device_property_count_u32(&client->dev, 411 + "adi,unlock-keys"); 412 + if (kpad->nkeys_unlock <= 0) { 413 + /* so that we don't end up enabling key lock */ 414 + kpad->nkeys_unlock = 0; 415 + return 0; 416 + } 417 + 418 + if (kpad->nkeys_unlock > ARRAY_SIZE(kpad->unlock_keys)) { 419 + dev_err(&client->dev, "number of unlock keys(%d) > (%zu)\n", 420 + kpad->nkeys_unlock, ARRAY_SIZE(kpad->unlock_keys)); 421 + return -EINVAL; 422 + } 423 + 424 + ret = device_property_read_u32_array(&client->dev, "adi,unlock-keys", 425 + kpad->unlock_keys, 426 + kpad->nkeys_unlock); 427 + if (ret) 428 + return ret; 429 + 430 + for (i = 0; i < kpad->nkeys_unlock; i++) { 431 + /* 432 + * Even though it should be possible (as stated in the datasheet) 433 + * to use GPIs (which are part of the keys event) as unlock keys, 434 + * it was not working at all and was leading to overflow events 435 + * at some point. Hence, for now, let's just allow keys which are 436 + * part of keypad matrix to be used and if a reliable way of 437 + * using GPIs is found, this condition can be removed/lightened. 438 + */ 439 + if (kpad->unlock_keys[i] >= kpad->cols * kpad->rows) { 440 + dev_err(&client->dev, "Invalid unlock key(%d)\n", 441 + kpad->unlock_keys[i]); 442 + return -EINVAL; 443 + } 444 + 445 + /* 446 + * Firmware properties keys start from 0 but on the device they 447 + * start from 1. 448 + */ 449 + kpad->unlock_keys[i] += 1; 658 450 } 659 451 660 452 return 0; 661 453 } 662 454 663 - static void adp5588_report_switch_state(struct adp5588_kpad *kpad) 455 + static void adp5588_disable_regulator(void *reg) 664 456 { 665 - int gpi_stat1 = adp5588_read(kpad->client, GPIO_DAT_STAT1); 666 - int gpi_stat2 = adp5588_read(kpad->client, GPIO_DAT_STAT2); 667 - int gpi_stat3 = adp5588_read(kpad->client, GPIO_DAT_STAT3); 668 - int gpi_stat_tmp, pin_loc; 669 - int i; 670 - 671 - for (i = 0; i < kpad->gpimapsize; i++) { 672 - unsigned short pin = kpad->gpimap[i].pin; 673 - 674 - if (pin <= GPI_PIN_ROW_END) { 675 - gpi_stat_tmp = gpi_stat1; 676 - pin_loc = pin - GPI_PIN_ROW_BASE; 677 - } else if ((pin - GPI_PIN_COL_BASE) < 8) { 678 - gpi_stat_tmp = gpi_stat2; 679 - pin_loc = pin - GPI_PIN_COL_BASE; 680 - } else { 681 - gpi_stat_tmp = gpi_stat3; 682 - pin_loc = pin - GPI_PIN_COL_BASE - 8; 683 - } 684 - 685 - if (gpi_stat_tmp < 0) { 686 - dev_err(&kpad->client->dev, 687 - "Can't read GPIO_DAT_STAT switch %d default to OFF\n", 688 - pin); 689 - gpi_stat_tmp = 0; 690 - } 691 - 692 - input_report_switch(kpad->input, 693 - kpad->gpimap[i].sw_evt, 694 - !(gpi_stat_tmp & (1 << pin_loc))); 695 - } 696 - 697 - input_sync(kpad->input); 457 + regulator_disable(reg); 698 458 } 699 - 700 459 701 460 static int adp5588_probe(struct i2c_client *client, 702 461 const struct i2c_device_id *id) 703 462 { 704 463 struct adp5588_kpad *kpad; 705 - const struct adp5588_kpad_platform_data *pdata = 706 - dev_get_platdata(&client->dev); 707 464 struct input_dev *input; 465 + struct gpio_desc *gpio; 466 + struct regulator *vcc; 708 467 unsigned int revid; 709 - int ret, i; 468 + int ret; 710 469 int error; 711 470 712 471 if (!i2c_check_functionality(client->adapter, 713 - I2C_FUNC_SMBUS_BYTE_DATA)) { 472 + I2C_FUNC_SMBUS_BYTE_DATA)) { 714 473 dev_err(&client->dev, "SMBUS Byte Data not Supported\n"); 715 474 return -EIO; 716 - } 717 - 718 - if (!pdata) { 719 - dev_err(&client->dev, "no platform data?\n"); 720 - return -EINVAL; 721 - } 722 - 723 - if (!pdata->rows || !pdata->cols || !pdata->keymap) { 724 - dev_err(&client->dev, "no rows, cols or keymap from pdata\n"); 725 - return -EINVAL; 726 - } 727 - 728 - if (pdata->keymapsize != ADP5588_KEYMAPSIZE) { 729 - dev_err(&client->dev, "invalid keymapsize\n"); 730 - return -EINVAL; 731 - } 732 - 733 - if (!pdata->gpimap && pdata->gpimapsize) { 734 - dev_err(&client->dev, "invalid gpimap from pdata\n"); 735 - return -EINVAL; 736 - } 737 - 738 - if (pdata->gpimapsize > ADP5588_GPIMAPSIZE_MAX) { 739 - dev_err(&client->dev, "invalid gpimapsize\n"); 740 - return -EINVAL; 741 - } 742 - 743 - for (i = 0; i < pdata->gpimapsize; i++) { 744 - unsigned short pin = pdata->gpimap[i].pin; 745 - 746 - if (pin < GPI_PIN_BASE || pin > GPI_PIN_END) { 747 - dev_err(&client->dev, "invalid gpi pin data\n"); 748 - return -EINVAL; 749 - } 750 - 751 - if (pin <= GPI_PIN_ROW_END) { 752 - if (pin - GPI_PIN_ROW_BASE + 1 <= pdata->rows) { 753 - dev_err(&client->dev, "invalid gpi row data\n"); 754 - return -EINVAL; 755 - } 756 - } else { 757 - if (pin - GPI_PIN_COL_BASE + 1 <= pdata->cols) { 758 - dev_err(&client->dev, "invalid gpi col data\n"); 759 - return -EINVAL; 760 - } 761 - } 762 - } 763 - 764 - if (!client->irq) { 765 - dev_err(&client->dev, "no IRQ?\n"); 766 - return -EINVAL; 767 475 } 768 476 769 477 kpad = devm_kzalloc(&client->dev, sizeof(*kpad), GFP_KERNEL); ··· 746 516 kpad->client = client; 747 517 kpad->input = input; 748 518 519 + error = adp5588_fw_parse(kpad); 520 + if (error) 521 + return error; 522 + 523 + vcc = devm_regulator_get(&client->dev, "vcc"); 524 + if (IS_ERR(vcc)) 525 + return PTR_ERR(vcc); 526 + 527 + error = regulator_enable(vcc); 528 + if (error) 529 + return error; 530 + 531 + error = devm_add_action_or_reset(&client->dev, 532 + adp5588_disable_regulator, vcc); 533 + if (error) 534 + return error; 535 + 536 + gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_HIGH); 537 + if (IS_ERR(gpio)) 538 + return PTR_ERR(gpio); 539 + 540 + if (gpio) { 541 + fsleep(30); 542 + gpiod_set_value_cansleep(gpio, 0); 543 + fsleep(60); 544 + } 545 + 749 546 ret = adp5588_read(client, DEV_ID); 750 547 if (ret < 0) 751 548 return ret; 752 549 753 - revid = (u8) ret & ADP5588_DEVICE_ID_MASK; 550 + revid = ret & ADP5588_DEVICE_ID_MASK; 754 551 if (WA_DELAYED_READOUT_REVID(revid)) 755 552 kpad->delay = msecs_to_jiffies(WA_DELAYED_READOUT_TIME); 756 553 ··· 791 534 input->id.product = 0x0001; 792 535 input->id.version = revid; 793 536 794 - input->keycodesize = sizeof(kpad->keycode[0]); 795 - input->keycodemax = pdata->keymapsize; 796 - input->keycode = kpad->keycode; 797 - 798 - memcpy(kpad->keycode, pdata->keymap, 799 - pdata->keymapsize * input->keycodesize); 800 - 801 - kpad->gpimap = pdata->gpimap; 802 - kpad->gpimapsize = pdata->gpimapsize; 803 - 804 - /* setup input device */ 805 - __set_bit(EV_KEY, input->evbit); 806 - 807 - if (pdata->repeat) 808 - __set_bit(EV_REP, input->evbit); 809 - 810 - for (i = 0; i < input->keycodemax; i++) 811 - if (kpad->keycode[i] <= KEY_MAX) 812 - __set_bit(kpad->keycode[i], input->keybit); 813 - __clear_bit(KEY_RESERVED, input->keybit); 814 - 815 - if (kpad->gpimapsize) 816 - __set_bit(EV_SW, input->evbit); 817 - for (i = 0; i < kpad->gpimapsize; i++) 818 - __set_bit(kpad->gpimap[i].sw_evt, input->swbit); 819 - 820 537 error = input_register_device(input); 821 538 if (error) { 822 539 dev_err(&client->dev, "unable to register input device: %d\n", 823 540 error); 824 541 return error; 825 542 } 543 + 544 + error = adp5588_setup(kpad); 545 + if (error) 546 + return error; 547 + 548 + error = adp5588_gpio_add(kpad); 549 + if (error) 550 + return error; 826 551 827 552 error = devm_request_threaded_irq(&client->dev, client->irq, 828 553 adp5588_hard_irq, adp5588_thread_irq, ··· 815 576 client->irq, error); 816 577 return error; 817 578 } 818 - 819 - error = adp5588_setup(client); 820 - if (error) 821 - return error; 822 - 823 - if (kpad->gpimapsize) 824 - adp5588_report_switch_state(kpad); 825 - 826 - error = adp5588_gpio_add(kpad); 827 - if (error) 828 - return error; 829 579 830 580 dev_info(&client->dev, "Rev.%d keypad, irq %d\n", revid, client->irq); 831 581 return 0; ··· 827 599 /* all resources will be freed by devm */ 828 600 } 829 601 830 - static int __maybe_unused adp5588_suspend(struct device *dev) 602 + static int adp5588_suspend(struct device *dev) 831 603 { 832 604 struct i2c_client *client = to_i2c_client(dev); 833 605 ··· 836 608 return 0; 837 609 } 838 610 839 - static int __maybe_unused adp5588_resume(struct device *dev) 611 + static int adp5588_resume(struct device *dev) 840 612 { 841 613 struct i2c_client *client = to_i2c_client(dev); 842 614 ··· 845 617 return 0; 846 618 } 847 619 848 - static SIMPLE_DEV_PM_OPS(adp5588_dev_pm_ops, adp5588_suspend, adp5588_resume); 620 + static DEFINE_SIMPLE_DEV_PM_OPS(adp5588_dev_pm_ops, adp5588_suspend, adp5588_resume); 849 621 850 622 static const struct i2c_device_id adp5588_id[] = { 851 623 { "adp5588-keys", 0 }, ··· 854 626 }; 855 627 MODULE_DEVICE_TABLE(i2c, adp5588_id); 856 628 629 + static const struct of_device_id adp5588_of_match[] = { 630 + { .compatible = "adi,adp5588" }, 631 + { .compatible = "adi,adp5587" }, 632 + {} 633 + }; 634 + MODULE_DEVICE_TABLE(of, adp5588_of_match); 635 + 857 636 static struct i2c_driver adp5588_driver = { 858 637 .driver = { 859 638 .name = KBUILD_MODNAME, 860 - .pm = &adp5588_dev_pm_ops, 639 + .of_match_table = adp5588_of_match, 640 + .pm = pm_sleep_ptr(&adp5588_dev_pm_ops), 861 641 }, 862 642 .probe = adp5588_probe, 863 643 .remove = adp5588_remove,
-3
drivers/input/keyboard/amikbd.c
··· 10 10 * Amiga keyboard driver for Linux/m68k 11 11 */ 12 12 13 - /* 14 - */ 15 - 16 13 #include <linux/module.h> 17 14 #include <linux/init.h> 18 15 #include <linux/input.h>
+2 -2
drivers/input/keyboard/applespi.c
··· 202 202 }; 203 203 204 204 /** 205 - * struct touchpad_info - touchpad info response. 205 + * struct touchpad_info_protocol - touchpad info response. 206 206 * message.type = 0x1020, message.length = 0x006e 207 207 * 208 208 * @unknown1: unknown ··· 311 311 struct command_protocol_mt_init init_mt_command; 312 312 struct command_protocol_capsl capsl_command; 313 313 struct command_protocol_bl bl_command; 314 - u8 data[0]; 314 + DECLARE_FLEX_ARRAY(u8, data); 315 315 }; 316 316 }; 317 317
-3
drivers/input/keyboard/atakbd.c
··· 21 21 * This driver only deals with handing key events off to the input layer. 22 22 */ 23 23 24 - /* 25 - */ 26 - 27 24 #include <linux/module.h> 28 25 #include <linux/init.h> 29 26 #include <linux/input.h>
+6 -10
drivers/input/keyboard/atkbd.c
··· 323 323 return attr->mode; 324 324 } 325 325 326 - static struct attribute_group atkbd_attribute_group = { 326 + static const struct attribute_group atkbd_attribute_group = { 327 327 .attrs = atkbd_attributes, 328 328 .is_visible = atkbd_attr_is_visible, 329 329 }; 330 + 331 + __ATTRIBUTE_GROUPS(atkbd_attribute); 330 332 331 333 static const unsigned int xl_table[] = { 332 334 ATKBD_RET_BAT, ATKBD_RET_ERR, ATKBD_RET_ACK, ··· 924 922 { 925 923 struct atkbd *atkbd = serio_get_drvdata(serio); 926 924 927 - sysfs_remove_group(&serio->dev.kobj, &atkbd_attribute_group); 928 - 929 925 atkbd_disable(atkbd); 930 926 931 927 input_unregister_device(atkbd->dev); ··· 1271 1271 atkbd_set_keycode_table(atkbd); 1272 1272 atkbd_set_device_attrs(atkbd); 1273 1273 1274 - err = sysfs_create_group(&serio->dev.kobj, &atkbd_attribute_group); 1275 - if (err) 1276 - goto fail3; 1277 - 1278 1274 atkbd_enable(atkbd); 1279 1275 if (serio->write) 1280 1276 atkbd_activate(atkbd); 1281 1277 1282 1278 err = input_register_device(atkbd->dev); 1283 1279 if (err) 1284 - goto fail4; 1280 + goto fail3; 1285 1281 1286 1282 return 0; 1287 1283 1288 - fail4: sysfs_remove_group(&serio->dev.kobj, &atkbd_attribute_group); 1289 1284 fail3: serio_close(serio); 1290 1285 fail2: serio_set_drvdata(serio, NULL); 1291 1286 fail1: input_free_device(dev); ··· 1373 1378 1374 1379 static struct serio_driver atkbd_drv = { 1375 1380 .driver = { 1376 - .name = "atkbd", 1381 + .name = "atkbd", 1382 + .dev_groups = atkbd_attribute_groups, 1377 1383 }, 1378 1384 .description = DRIVER_DESC, 1379 1385 .id_table = atkbd_serio_ids,
+7 -6
drivers/input/keyboard/clps711x-keypad.c
··· 6 6 */ 7 7 8 8 #include <linux/input.h> 9 + #include <linux/mod_devicetable.h> 9 10 #include <linux/module.h> 10 - #include <linux/of_gpio.h> 11 + #include <linux/gpio/consumer.h> 11 12 #include <linux/platform_device.h> 13 + #include <linux/property.h> 12 14 #include <linux/regmap.h> 13 15 #include <linux/sched.h> 14 16 #include <linux/input/matrix_keypad.h> ··· 88 86 { 89 87 struct clps711x_keypad_data *priv; 90 88 struct device *dev = &pdev->dev; 91 - struct device_node *np = dev->of_node; 92 89 struct input_dev *input; 93 90 u32 poll_interval; 94 91 int i, err; ··· 96 95 if (!priv) 97 96 return -ENOMEM; 98 97 99 - priv->syscon = syscon_regmap_lookup_by_phandle(np, "syscon"); 98 + priv->syscon = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon"); 100 99 if (IS_ERR(priv->syscon)) 101 100 return PTR_ERR(priv->syscon); 102 101 103 - priv->row_count = of_gpio_named_count(np, "row-gpios"); 102 + priv->row_count = gpiod_count(dev, "row"); 104 103 if (priv->row_count < 1) 105 104 return -EINVAL; 106 105 ··· 120 119 return PTR_ERR(data->desc); 121 120 } 122 121 123 - err = of_property_read_u32(np, "poll-interval", &poll_interval); 122 + err = device_property_read_u32(dev, "poll-interval", &poll_interval); 124 123 if (err) 125 124 return err; 126 125 ··· 144 143 return err; 145 144 146 145 input_set_capability(input, EV_MSC, MSC_SCAN); 147 - if (of_property_read_bool(np, "autorepeat")) 146 + if (device_property_read_bool(dev, "autorepeat")) 148 147 __set_bit(EV_REP, input->evbit); 149 148 150 149 /* Set all columns to low */
+1
drivers/input/keyboard/ep93xx_keypad.c
··· 23 23 #include <linux/interrupt.h> 24 24 #include <linux/clk.h> 25 25 #include <linux/io.h> 26 + #include <linux/input.h> 26 27 #include <linux/input/matrix_keypad.h> 27 28 #include <linux/slab.h> 28 29 #include <linux/soc/cirrus/ep93xx.h>
+1
drivers/input/keyboard/imx_keypad.c
··· 7 7 #include <linux/delay.h> 8 8 #include <linux/device.h> 9 9 #include <linux/err.h> 10 + #include <linux/input.h> 10 11 #include <linux/input/matrix_keypad.h> 11 12 #include <linux/interrupt.h> 12 13 #include <linux/io.h>
+4 -7
drivers/input/keyboard/lkkbd.c
··· 46 46 * http://www.vt100.net/manx/details?pn=EK-104AA-TM-001;id=21;cp=1 47 47 */ 48 48 49 - /* 50 - */ 51 - 52 49 #include <linux/delay.h> 53 50 #include <linux/slab.h> 54 51 #include <linux/module.h> ··· 356 359 */ 357 360 switch (lk->id[4]) { 358 361 case 1: 359 - strlcpy(lk->name, "DEC LK201 keyboard", sizeof(lk->name)); 362 + strscpy(lk->name, "DEC LK201 keyboard", sizeof(lk->name)); 360 363 361 364 if (lk201_compose_is_alt) 362 365 lk->keycode[0xb1] = KEY_LEFTALT; 363 366 break; 364 367 365 368 case 2: 366 - strlcpy(lk->name, "DEC LK401 keyboard", sizeof(lk->name)); 369 + strscpy(lk->name, "DEC LK401 keyboard", sizeof(lk->name)); 367 370 break; 368 371 369 372 default: 370 - strlcpy(lk->name, "Unknown DEC keyboard", sizeof(lk->name)); 373 + strscpy(lk->name, "Unknown DEC keyboard", sizeof(lk->name)); 371 374 printk(KERN_ERR 372 375 "lkkbd: keyboard on %s is unknown, please report to " 373 376 "Jan-Benedict Glaw <jbglaw@lug-owl.de>\n", lk->phys); ··· 623 626 lk->ctrlclick_volume = ctrlclick_volume; 624 627 memcpy(lk->keycode, lkkbd_keycode, sizeof(lk->keycode)); 625 628 626 - strlcpy(lk->name, "DEC LK keyboard", sizeof(lk->name)); 629 + strscpy(lk->name, "DEC LK keyboard", sizeof(lk->name)); 627 630 snprintf(lk->phys, sizeof(lk->phys), "%s/input0", serio->phys); 628 631 629 632 input_dev->name = lk->name;
+4 -4
drivers/input/keyboard/lm8333.c
··· 4 4 * Copyright (C) 2012 Wolfram Sang, Pengutronix <kernel@pengutronix.de> 5 5 */ 6 6 7 - #include <linux/module.h> 8 - #include <linux/slab.h> 9 - #include <linux/irq.h> 10 7 #include <linux/i2c.h> 11 - #include <linux/interrupt.h> 8 + #include <linux/input.h> 12 9 #include <linux/input/matrix_keypad.h> 13 10 #include <linux/input/lm8333.h> 11 + #include <linux/interrupt.h> 12 + #include <linux/module.h> 13 + #include <linux/slab.h> 14 14 15 15 #define LM8333_FIFO_READ 0x20 16 16 #define LM8333_DEBOUNCE 0x22
+4 -3
drivers/input/keyboard/matrix_keypad.c
··· 9 9 10 10 #include <linux/types.h> 11 11 #include <linux/delay.h> 12 + #include <linux/gpio/consumer.h> 12 13 #include <linux/platform_device.h> 13 14 #include <linux/input.h> 14 15 #include <linux/irq.h> ··· 417 416 return ERR_PTR(-ENOMEM); 418 417 } 419 418 420 - pdata->num_row_gpios = nrow = of_gpio_named_count(np, "row-gpios"); 421 - pdata->num_col_gpios = ncol = of_gpio_named_count(np, "col-gpios"); 422 - if (nrow <= 0 || ncol <= 0) { 419 + pdata->num_row_gpios = nrow = gpiod_count(dev, "row"); 420 + pdata->num_col_gpios = ncol = gpiod_count(dev, "col"); 421 + if (nrow < 0 || ncol < 0) { 423 422 dev_err(dev, "number of keypad rows/columns not specified\n"); 424 423 return ERR_PTR(-EINVAL); 425 424 }
+44 -2
drivers/input/keyboard/mt6779-keypad.c
··· 5 5 */ 6 6 #include <linux/bitops.h> 7 7 #include <linux/clk.h> 8 + #include <linux/input.h> 8 9 #include <linux/input/matrix_keypad.h> 9 10 #include <linux/interrupt.h> 10 11 #include <linux/module.h> ··· 19 18 #define MTK_KPD_DEBOUNCE_MASK GENMASK(13, 0) 20 19 #define MTK_KPD_DEBOUNCE_MAX_MS 256 21 20 #define MTK_KPD_SEL 0x0020 21 + #define MTK_KPD_SEL_DOUBLE_KP_MODE BIT(0) 22 22 #define MTK_KPD_SEL_COL GENMASK(15, 10) 23 23 #define MTK_KPD_SEL_ROW GENMASK(9, 4) 24 24 #define MTK_KPD_SEL_COLMASK(c) GENMASK((c) + 9, 10) ··· 33 31 struct clk *clk; 34 32 u32 n_rows; 35 33 u32 n_cols; 34 + void (*calc_row_col)(unsigned int key, 35 + unsigned int *row, unsigned int *col); 36 36 DECLARE_BITMAP(keymap_state, MTK_KPD_NUM_BITS); 37 37 }; 38 38 ··· 71 67 continue; 72 68 73 69 key = bit_nr / 32 * 16 + bit_nr % 32; 74 - row = key / 9; 75 - col = key % 9; 70 + keypad->calc_row_col(key, &row, &col); 76 71 77 72 scancode = MATRIX_SCAN_CODE(row, col, row_shift); 78 73 /* 1: not pressed, 0: pressed */ ··· 97 94 clk_disable_unprepare(data); 98 95 } 99 96 97 + static void mt6779_keypad_calc_row_col_single(unsigned int key, 98 + unsigned int *row, 99 + unsigned int *col) 100 + { 101 + *row = key / 9; 102 + *col = key % 9; 103 + } 104 + 105 + static void mt6779_keypad_calc_row_col_double(unsigned int key, 106 + unsigned int *row, 107 + unsigned int *col) 108 + { 109 + *row = key / 13; 110 + *col = (key % 13) / 2; 111 + } 112 + 100 113 static int mt6779_keypad_pdrv_probe(struct platform_device *pdev) 101 114 { 102 115 struct mt6779_keypad *keypad; 103 116 void __iomem *base; 104 117 int irq; 105 118 u32 debounce; 119 + u32 keys_per_group; 106 120 bool wakeup; 107 121 int error; 108 122 ··· 168 148 return -EINVAL; 169 149 } 170 150 151 + if (device_property_read_u32(&pdev->dev, "mediatek,keys-per-group", 152 + &keys_per_group)) 153 + keys_per_group = 1; 154 + 155 + switch (keys_per_group) { 156 + case 1: 157 + keypad->calc_row_col = mt6779_keypad_calc_row_col_single; 158 + break; 159 + case 2: 160 + keypad->calc_row_col = mt6779_keypad_calc_row_col_double; 161 + break; 162 + default: 163 + dev_err(&pdev->dev, 164 + "Invalid keys-per-group: %d\n", keys_per_group); 165 + return -EINVAL; 166 + } 167 + 171 168 wakeup = device_property_read_bool(&pdev->dev, "wakeup-source"); 172 169 173 170 dev_dbg(&pdev->dev, "n_row=%d n_col=%d debounce=%d\n", ··· 202 165 203 166 regmap_write(keypad->regmap, MTK_KPD_DEBOUNCE, 204 167 (debounce * (1 << 5)) & MTK_KPD_DEBOUNCE_MASK); 168 + 169 + if (keys_per_group == 2) 170 + regmap_update_bits(keypad->regmap, MTK_KPD_SEL, 171 + MTK_KPD_SEL_DOUBLE_KP_MODE, 172 + MTK_KPD_SEL_DOUBLE_KP_MODE); 205 173 206 174 regmap_update_bits(keypad->regmap, MTK_KPD_SEL, MTK_KPD_SEL_ROW, 207 175 MTK_KPD_SEL_ROWMASK(keypad->n_rows));
+21
drivers/input/keyboard/mtk-pmic-keys.c
··· 9 9 #include <linux/interrupt.h> 10 10 #include <linux/kernel.h> 11 11 #include <linux/mfd/mt6323/registers.h> 12 + #include <linux/mfd/mt6331/registers.h> 12 13 #include <linux/mfd/mt6358/registers.h> 13 14 #include <linux/mfd/mt6397/core.h> 14 15 #include <linux/mfd/mt6397/registers.h> ··· 22 21 #define MTK_PMIC_RST_DU_MASK GENMASK(9, 8) 23 22 #define MTK_PMIC_PWRKEY_RST BIT(6) 24 23 #define MTK_PMIC_HOMEKEY_RST BIT(5) 24 + 25 + #define MTK_PMIC_MT6331_RST_DU_MASK GENMASK(13, 12) 26 + #define MTK_PMIC_MT6331_PWRKEY_RST BIT(9) 27 + #define MTK_PMIC_MT6331_HOMEKEY_RST BIT(8) 25 28 26 29 #define MTK_PMIC_PWRKEY_INDEX 0 27 30 #define MTK_PMIC_HOMEKEY_INDEX 1 ··· 75 70 0x4, MT6323_INT_MISC_CON, 0x8, MTK_PMIC_HOMEKEY_RST), 76 71 .pmic_rst_reg = MT6323_TOP_RST_MISC, 77 72 .rst_lprst_mask = MTK_PMIC_RST_DU_MASK, 73 + }; 74 + 75 + static const struct mtk_pmic_regs mt6331_regs = { 76 + .keys_regs[MTK_PMIC_PWRKEY_INDEX] = 77 + MTK_PMIC_KEYS_REGS(MT6331_TOPSTATUS, 0x2, 78 + MT6331_INT_MISC_CON, 0x4, 79 + MTK_PMIC_MT6331_PWRKEY_RST), 80 + .keys_regs[MTK_PMIC_HOMEKEY_INDEX] = 81 + MTK_PMIC_KEYS_REGS(MT6331_TOPSTATUS, 0x4, 82 + MT6331_INT_MISC_CON, 0x2, 83 + MTK_PMIC_MT6331_HOMEKEY_RST), 84 + .pmic_rst_reg = MT6331_TOP_RST_MISC, 85 + .rst_lprst_mask = MTK_PMIC_MT6331_RST_DU_MASK, 78 86 }; 79 87 80 88 static const struct mtk_pmic_regs mt6358_regs = { ··· 273 255 }, { 274 256 .compatible = "mediatek,mt6323-keys", 275 257 .data = &mt6323_regs, 258 + }, { 259 + .compatible = "mediatek,mt6331-keys", 260 + .data = &mt6331_regs, 276 261 }, { 277 262 .compatible = "mediatek,mt6358-keys", 278 263 .data = &mt6358_regs,
-3
drivers/input/keyboard/newtonkbd.c
··· 7 7 * Newton keyboard driver for Linux 8 8 */ 9 9 10 - /* 11 - */ 12 - 13 10 #include <linux/slab.h> 14 11 #include <linux/module.h> 15 12 #include <linux/input.h>
+468
drivers/input/keyboard/pinephone-keyboard.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + // 3 + // Copyright (C) 2021-2022 Samuel Holland <samuel@sholland.org> 4 + 5 + #include <linux/crc8.h> 6 + #include <linux/delay.h> 7 + #include <linux/err.h> 8 + #include <linux/i2c.h> 9 + #include <linux/input.h> 10 + #include <linux/input/matrix_keypad.h> 11 + #include <linux/interrupt.h> 12 + #include <linux/module.h> 13 + #include <linux/mod_devicetable.h> 14 + #include <linux/of.h> 15 + #include <linux/regulator/consumer.h> 16 + #include <linux/types.h> 17 + 18 + #define DRV_NAME "pinephone-keyboard" 19 + 20 + #define PPKB_CRC8_POLYNOMIAL 0x07 21 + 22 + #define PPKB_DEVICE_ID_HI 0x00 23 + #define PPKB_DEVICE_ID_HI_VALUE 'K' 24 + #define PPKB_DEVICE_ID_LO 0x01 25 + #define PPKB_DEVICE_ID_LO_VALUE 'B' 26 + #define PPKB_FW_REVISION 0x02 27 + #define PPKB_FW_FEATURES 0x03 28 + #define PPKB_MATRIX_SIZE 0x06 29 + #define PPKB_SCAN_CRC 0x07 30 + #define PPKB_SCAN_DATA 0x08 31 + #define PPKB_SYS_CONFIG 0x20 32 + #define PPKB_SYS_CONFIG_DISABLE_SCAN BIT(0) 33 + #define PPKB_SYS_SMBUS_COMMAND 0x21 34 + #define PPKB_SYS_SMBUS_DATA 0x22 35 + #define PPKB_SYS_COMMAND 0x23 36 + #define PPKB_SYS_COMMAND_SMBUS_READ 0x91 37 + #define PPKB_SYS_COMMAND_SMBUS_WRITE 0xa1 38 + 39 + #define PPKB_ROWS 6 40 + #define PPKB_COLS 12 41 + 42 + /* Size of the scan buffer, including the CRC byte at the beginning. */ 43 + #define PPKB_BUF_LEN (1 + PPKB_COLS) 44 + 45 + static const uint32_t ppkb_keymap[] = { 46 + KEY(0, 0, KEY_ESC), 47 + KEY(0, 1, KEY_1), 48 + KEY(0, 2, KEY_2), 49 + KEY(0, 3, KEY_3), 50 + KEY(0, 4, KEY_4), 51 + KEY(0, 5, KEY_5), 52 + KEY(0, 6, KEY_6), 53 + KEY(0, 7, KEY_7), 54 + KEY(0, 8, KEY_8), 55 + KEY(0, 9, KEY_9), 56 + KEY(0, 10, KEY_0), 57 + KEY(0, 11, KEY_BACKSPACE), 58 + 59 + KEY(1, 0, KEY_TAB), 60 + KEY(1, 1, KEY_Q), 61 + KEY(1, 2, KEY_W), 62 + KEY(1, 3, KEY_E), 63 + KEY(1, 4, KEY_R), 64 + KEY(1, 5, KEY_T), 65 + KEY(1, 6, KEY_Y), 66 + KEY(1, 7, KEY_U), 67 + KEY(1, 8, KEY_I), 68 + KEY(1, 9, KEY_O), 69 + KEY(1, 10, KEY_P), 70 + KEY(1, 11, KEY_ENTER), 71 + 72 + KEY(2, 0, KEY_LEFTMETA), 73 + KEY(2, 1, KEY_A), 74 + KEY(2, 2, KEY_S), 75 + KEY(2, 3, KEY_D), 76 + KEY(2, 4, KEY_F), 77 + KEY(2, 5, KEY_G), 78 + KEY(2, 6, KEY_H), 79 + KEY(2, 7, KEY_J), 80 + KEY(2, 8, KEY_K), 81 + KEY(2, 9, KEY_L), 82 + KEY(2, 10, KEY_SEMICOLON), 83 + 84 + KEY(3, 0, KEY_LEFTSHIFT), 85 + KEY(3, 1, KEY_Z), 86 + KEY(3, 2, KEY_X), 87 + KEY(3, 3, KEY_C), 88 + KEY(3, 4, KEY_V), 89 + KEY(3, 5, KEY_B), 90 + KEY(3, 6, KEY_N), 91 + KEY(3, 7, KEY_M), 92 + KEY(3, 8, KEY_COMMA), 93 + KEY(3, 9, KEY_DOT), 94 + KEY(3, 10, KEY_SLASH), 95 + 96 + KEY(4, 1, KEY_LEFTCTRL), 97 + KEY(4, 4, KEY_SPACE), 98 + KEY(4, 6, KEY_APOSTROPHE), 99 + KEY(4, 8, KEY_RIGHTBRACE), 100 + KEY(4, 9, KEY_LEFTBRACE), 101 + 102 + KEY(5, 2, KEY_FN), 103 + KEY(5, 3, KEY_LEFTALT), 104 + KEY(5, 5, KEY_RIGHTALT), 105 + 106 + /* FN layer */ 107 + KEY(PPKB_ROWS + 0, 0, KEY_FN_ESC), 108 + KEY(PPKB_ROWS + 0, 1, KEY_F1), 109 + KEY(PPKB_ROWS + 0, 2, KEY_F2), 110 + KEY(PPKB_ROWS + 0, 3, KEY_F3), 111 + KEY(PPKB_ROWS + 0, 4, KEY_F4), 112 + KEY(PPKB_ROWS + 0, 5, KEY_F5), 113 + KEY(PPKB_ROWS + 0, 6, KEY_F6), 114 + KEY(PPKB_ROWS + 0, 7, KEY_F7), 115 + KEY(PPKB_ROWS + 0, 8, KEY_F8), 116 + KEY(PPKB_ROWS + 0, 9, KEY_F9), 117 + KEY(PPKB_ROWS + 0, 10, KEY_F10), 118 + KEY(PPKB_ROWS + 0, 11, KEY_DELETE), 119 + 120 + KEY(PPKB_ROWS + 1, 10, KEY_PAGEUP), 121 + 122 + KEY(PPKB_ROWS + 2, 0, KEY_SYSRQ), 123 + KEY(PPKB_ROWS + 2, 9, KEY_PAGEDOWN), 124 + KEY(PPKB_ROWS + 2, 10, KEY_INSERT), 125 + 126 + KEY(PPKB_ROWS + 3, 0, KEY_LEFTSHIFT), 127 + KEY(PPKB_ROWS + 3, 8, KEY_HOME), 128 + KEY(PPKB_ROWS + 3, 9, KEY_UP), 129 + KEY(PPKB_ROWS + 3, 10, KEY_END), 130 + 131 + KEY(PPKB_ROWS + 4, 1, KEY_LEFTCTRL), 132 + KEY(PPKB_ROWS + 4, 6, KEY_LEFT), 133 + KEY(PPKB_ROWS + 4, 8, KEY_RIGHT), 134 + KEY(PPKB_ROWS + 4, 9, KEY_DOWN), 135 + 136 + KEY(PPKB_ROWS + 5, 3, KEY_LEFTALT), 137 + KEY(PPKB_ROWS + 5, 5, KEY_RIGHTALT), 138 + }; 139 + 140 + static const struct matrix_keymap_data ppkb_keymap_data = { 141 + .keymap = ppkb_keymap, 142 + .keymap_size = ARRAY_SIZE(ppkb_keymap), 143 + }; 144 + 145 + struct pinephone_keyboard { 146 + struct i2c_adapter adapter; 147 + struct input_dev *input; 148 + u8 buf[2][PPKB_BUF_LEN]; 149 + u8 crc_table[CRC8_TABLE_SIZE]; 150 + u8 fn_state[PPKB_COLS]; 151 + bool buf_swap; 152 + bool fn_pressed; 153 + }; 154 + 155 + static int ppkb_adap_smbus_xfer(struct i2c_adapter *adap, u16 addr, 156 + unsigned short flags, char read_write, 157 + u8 command, int size, 158 + union i2c_smbus_data *data) 159 + { 160 + struct i2c_client *client = adap->algo_data; 161 + u8 buf[3]; 162 + int ret; 163 + 164 + buf[0] = command; 165 + buf[1] = data->byte; 166 + buf[2] = read_write == I2C_SMBUS_READ ? PPKB_SYS_COMMAND_SMBUS_READ 167 + : PPKB_SYS_COMMAND_SMBUS_WRITE; 168 + 169 + ret = i2c_smbus_write_i2c_block_data(client, PPKB_SYS_SMBUS_COMMAND, 170 + sizeof(buf), buf); 171 + if (ret) 172 + return ret; 173 + 174 + /* Read back the command status until it passes or fails. */ 175 + do { 176 + usleep_range(300, 500); 177 + ret = i2c_smbus_read_byte_data(client, PPKB_SYS_COMMAND); 178 + } while (ret == buf[2]); 179 + if (ret < 0) 180 + return ret; 181 + /* Commands return 0x00 on success and 0xff on failure. */ 182 + if (ret) 183 + return -EIO; 184 + 185 + if (read_write == I2C_SMBUS_READ) { 186 + ret = i2c_smbus_read_byte_data(client, PPKB_SYS_SMBUS_DATA); 187 + if (ret < 0) 188 + return ret; 189 + 190 + data->byte = ret; 191 + } 192 + 193 + return 0; 194 + } 195 + 196 + static u32 ppkg_adap_functionality(struct i2c_adapter *adap) 197 + { 198 + return I2C_FUNC_SMBUS_BYTE_DATA; 199 + } 200 + 201 + static const struct i2c_algorithm ppkb_adap_algo = { 202 + .smbus_xfer = ppkb_adap_smbus_xfer, 203 + .functionality = ppkg_adap_functionality, 204 + }; 205 + 206 + static void ppkb_update(struct i2c_client *client) 207 + { 208 + struct pinephone_keyboard *ppkb = i2c_get_clientdata(client); 209 + unsigned short *keymap = ppkb->input->keycode; 210 + int row_shift = get_count_order(PPKB_COLS); 211 + u8 *old_buf = ppkb->buf[!ppkb->buf_swap]; 212 + u8 *new_buf = ppkb->buf[ppkb->buf_swap]; 213 + int col, crc, ret, row; 214 + struct device *dev = &client->dev; 215 + 216 + ret = i2c_smbus_read_i2c_block_data(client, PPKB_SCAN_CRC, 217 + PPKB_BUF_LEN, new_buf); 218 + if (ret != PPKB_BUF_LEN) { 219 + dev_err(dev, "Failed to read scan data: %d\n", ret); 220 + return; 221 + } 222 + 223 + crc = crc8(ppkb->crc_table, &new_buf[1], PPKB_COLS, CRC8_INIT_VALUE); 224 + if (crc != new_buf[0]) { 225 + dev_err(dev, "Bad scan data (%02x != %02x)\n", crc, new_buf[0]); 226 + return; 227 + } 228 + 229 + ppkb->buf_swap = !ppkb->buf_swap; 230 + 231 + for (col = 0; col < PPKB_COLS; ++col) { 232 + u8 old = old_buf[1 + col]; 233 + u8 new = new_buf[1 + col]; 234 + u8 changed = old ^ new; 235 + 236 + if (!changed) 237 + continue; 238 + 239 + for (row = 0; row < PPKB_ROWS; ++row) { 240 + u8 mask = BIT(row); 241 + u8 value = new & mask; 242 + unsigned short code; 243 + bool fn_state; 244 + 245 + if (!(changed & mask)) 246 + continue; 247 + 248 + /* 249 + * Save off the FN key state when the key was pressed, 250 + * and use that to determine the code during a release. 251 + */ 252 + fn_state = value ? ppkb->fn_pressed : ppkb->fn_state[col] & mask; 253 + if (fn_state) 254 + ppkb->fn_state[col] ^= mask; 255 + 256 + /* The FN layer is a second set of rows. */ 257 + code = MATRIX_SCAN_CODE(fn_state ? PPKB_ROWS + row : row, 258 + col, row_shift); 259 + input_event(ppkb->input, EV_MSC, MSC_SCAN, code); 260 + input_report_key(ppkb->input, keymap[code], value); 261 + if (keymap[code] == KEY_FN) 262 + ppkb->fn_pressed = value; 263 + } 264 + } 265 + input_sync(ppkb->input); 266 + } 267 + 268 + static irqreturn_t ppkb_irq_thread(int irq, void *data) 269 + { 270 + struct i2c_client *client = data; 271 + 272 + ppkb_update(client); 273 + 274 + return IRQ_HANDLED; 275 + } 276 + 277 + static int ppkb_set_scan(struct i2c_client *client, bool enable) 278 + { 279 + struct device *dev = &client->dev; 280 + int ret, val; 281 + 282 + ret = i2c_smbus_read_byte_data(client, PPKB_SYS_CONFIG); 283 + if (ret < 0) { 284 + dev_err(dev, "Failed to read config: %d\n", ret); 285 + return ret; 286 + } 287 + 288 + if (enable) 289 + val = ret & ~PPKB_SYS_CONFIG_DISABLE_SCAN; 290 + else 291 + val = ret | PPKB_SYS_CONFIG_DISABLE_SCAN; 292 + 293 + ret = i2c_smbus_write_byte_data(client, PPKB_SYS_CONFIG, val); 294 + if (ret) { 295 + dev_err(dev, "Failed to write config: %d\n", ret); 296 + return ret; 297 + } 298 + 299 + return 0; 300 + } 301 + 302 + static int ppkb_open(struct input_dev *input) 303 + { 304 + struct i2c_client *client = input_get_drvdata(input); 305 + int error; 306 + 307 + error = ppkb_set_scan(client, true); 308 + if (error) 309 + return error; 310 + 311 + return 0; 312 + } 313 + 314 + static void ppkb_close(struct input_dev *input) 315 + { 316 + struct i2c_client *client = input_get_drvdata(input); 317 + 318 + ppkb_set_scan(client, false); 319 + } 320 + 321 + static void ppkb_regulator_disable(void *regulator) 322 + { 323 + regulator_disable(regulator); 324 + } 325 + 326 + static int ppkb_probe(struct i2c_client *client) 327 + { 328 + struct device *dev = &client->dev; 329 + unsigned int phys_rows, phys_cols; 330 + struct pinephone_keyboard *ppkb; 331 + struct regulator *vbat_supply; 332 + u8 info[PPKB_MATRIX_SIZE + 1]; 333 + struct device_node *i2c_bus; 334 + int ret; 335 + int error; 336 + 337 + vbat_supply = devm_regulator_get(dev, "vbat"); 338 + error = PTR_ERR_OR_ZERO(vbat_supply); 339 + if (error) { 340 + dev_err(dev, "Failed to get VBAT supply: %d\n", error); 341 + return error; 342 + } 343 + 344 + error = regulator_enable(vbat_supply); 345 + if (error) { 346 + dev_err(dev, "Failed to enable VBAT: %d\n", error); 347 + return error; 348 + } 349 + 350 + error = devm_add_action_or_reset(dev, ppkb_regulator_disable, 351 + vbat_supply); 352 + if (error) 353 + return error; 354 + 355 + ret = i2c_smbus_read_i2c_block_data(client, 0, sizeof(info), info); 356 + if (ret != sizeof(info)) { 357 + error = ret < 0 ? ret : -EIO; 358 + dev_err(dev, "Failed to read device ID: %d\n", error); 359 + return error; 360 + } 361 + 362 + if (info[PPKB_DEVICE_ID_HI] != PPKB_DEVICE_ID_HI_VALUE || 363 + info[PPKB_DEVICE_ID_LO] != PPKB_DEVICE_ID_LO_VALUE) { 364 + dev_warn(dev, "Unexpected device ID: %#02x %#02x\n", 365 + info[PPKB_DEVICE_ID_HI], info[PPKB_DEVICE_ID_LO]); 366 + return -ENODEV; 367 + } 368 + 369 + dev_info(dev, "Found firmware version %d.%d features %#x\n", 370 + info[PPKB_FW_REVISION] >> 4, 371 + info[PPKB_FW_REVISION] & 0xf, 372 + info[PPKB_FW_FEATURES]); 373 + 374 + phys_rows = info[PPKB_MATRIX_SIZE] & 0xf; 375 + phys_cols = info[PPKB_MATRIX_SIZE] >> 4; 376 + if (phys_rows != PPKB_ROWS || phys_cols != PPKB_COLS) { 377 + dev_err(dev, "Unexpected keyboard size %ux%u\n", 378 + phys_rows, phys_cols); 379 + return -EINVAL; 380 + } 381 + 382 + /* Disable scan by default to save power. */ 383 + error = ppkb_set_scan(client, false); 384 + if (error) 385 + return error; 386 + 387 + ppkb = devm_kzalloc(dev, sizeof(*ppkb), GFP_KERNEL); 388 + if (!ppkb) 389 + return -ENOMEM; 390 + 391 + i2c_set_clientdata(client, ppkb); 392 + 393 + i2c_bus = of_get_child_by_name(dev->of_node, "i2c"); 394 + if (i2c_bus) { 395 + ppkb->adapter.owner = THIS_MODULE; 396 + ppkb->adapter.algo = &ppkb_adap_algo; 397 + ppkb->adapter.algo_data = client; 398 + ppkb->adapter.dev.parent = dev; 399 + ppkb->adapter.dev.of_node = i2c_bus; 400 + strscpy(ppkb->adapter.name, DRV_NAME, sizeof(ppkb->adapter.name)); 401 + 402 + error = devm_i2c_add_adapter(dev, &ppkb->adapter); 403 + if (error) { 404 + dev_err(dev, "Failed to add I2C adapter: %d\n", error); 405 + return error; 406 + } 407 + } 408 + 409 + crc8_populate_msb(ppkb->crc_table, PPKB_CRC8_POLYNOMIAL); 410 + 411 + ppkb->input = devm_input_allocate_device(dev); 412 + if (!ppkb->input) 413 + return -ENOMEM; 414 + 415 + input_set_drvdata(ppkb->input, client); 416 + 417 + ppkb->input->name = "PinePhone Keyboard"; 418 + ppkb->input->phys = DRV_NAME "/input0"; 419 + ppkb->input->id.bustype = BUS_I2C; 420 + ppkb->input->open = ppkb_open; 421 + ppkb->input->close = ppkb_close; 422 + 423 + input_set_capability(ppkb->input, EV_MSC, MSC_SCAN); 424 + __set_bit(EV_REP, ppkb->input->evbit); 425 + 426 + error = matrix_keypad_build_keymap(&ppkb_keymap_data, NULL, 427 + 2 * PPKB_ROWS, PPKB_COLS, NULL, 428 + ppkb->input); 429 + if (error) { 430 + dev_err(dev, "Failed to build keymap: %d\n", error); 431 + return error; 432 + } 433 + 434 + error = input_register_device(ppkb->input); 435 + if (error) { 436 + dev_err(dev, "Failed to register input: %d\n", error); 437 + return error; 438 + } 439 + 440 + error = devm_request_threaded_irq(dev, client->irq, 441 + NULL, ppkb_irq_thread, 442 + IRQF_ONESHOT, client->name, client); 443 + if (error) { 444 + dev_err(dev, "Failed to request IRQ: %d\n", error); 445 + return error; 446 + } 447 + 448 + return 0; 449 + } 450 + 451 + static const struct of_device_id ppkb_of_match[] = { 452 + { .compatible = "pine64,pinephone-keyboard" }, 453 + { } 454 + }; 455 + MODULE_DEVICE_TABLE(of, ppkb_of_match); 456 + 457 + static struct i2c_driver ppkb_driver = { 458 + .probe_new = ppkb_probe, 459 + .driver = { 460 + .name = DRV_NAME, 461 + .of_match_table = ppkb_of_match, 462 + }, 463 + }; 464 + module_i2c_driver(ppkb_driver); 465 + 466 + MODULE_AUTHOR("Samuel Holland <samuel@sholland.org>"); 467 + MODULE_DESCRIPTION("Pine64 PinePhone keyboard driver"); 468 + MODULE_LICENSE("GPL");
+6 -4
drivers/input/keyboard/st-keyscan.c
··· 8 8 * Based on sh_keysc.c, copyright 2008 Magnus Damm 9 9 */ 10 10 11 - #include <linux/module.h> 12 - #include <linux/interrupt.h> 13 - #include <linux/platform_device.h> 14 11 #include <linux/clk.h> 15 - #include <linux/io.h> 12 + #include <linux/input.h> 16 13 #include <linux/input/matrix_keypad.h> 14 + #include <linux/io.h> 15 + #include <linux/interrupt.h> 16 + #include <linux/module.h> 17 + #include <linux/of.h> 18 + #include <linux/platform_device.h> 17 19 18 20 #define ST_KEYSCAN_MAXKEYS 16 19 21
-3
drivers/input/keyboard/stowaway.c
··· 10 10 * by Justin Cormack 11 11 */ 12 12 13 - /* 14 - */ 15 - 16 13 #include <linux/slab.h> 17 14 #include <linux/module.h> 18 15 #include <linux/input.h>
-3
drivers/input/keyboard/sunkbd.c
··· 7 7 * Sun keyboard driver for Linux 8 8 */ 9 9 10 - /* 11 - */ 12 - 13 10 #include <linux/delay.h> 14 11 #include <linux/sched.h> 15 12 #include <linux/slab.h>
+1 -1
drivers/input/keyboard/tc3589x-keypad.c
··· 70 70 #define TC3589x_KBD_INT_CLR 0x1 71 71 72 72 /** 73 - * struct tc35893_keypad_platform_data - platform specific keypad data 73 + * struct tc3589x_keypad_platform_data - platform specific keypad data 74 74 * @keymap_data: matrix scan code table for keycodes 75 75 * @krow: mask for available rows, value is 0xFF 76 76 * @kcol: mask for available columns, value is 0xFF
-3
drivers/input/keyboard/xtkbd.c
··· 7 7 * XT keyboard driver for Linux 8 8 */ 9 9 10 - /* 11 - */ 12 - 13 10 #include <linux/slab.h> 14 11 #include <linux/module.h> 15 12 #include <linux/input.h>
+27
drivers/input/misc/Kconfig
··· 730 730 To compile this driver as a module, choose M here: the 731 731 module will be called adxl34x-spi. 732 732 733 + config INPUT_IBM_PANEL 734 + tristate "IBM Operation Panel driver" 735 + depends on I2C && I2C_SLAVE 736 + help 737 + Say Y here if you have an IBM Operation Panel connected to your system 738 + over I2C. The panel is typically connected only to a system's service 739 + processor (BMC). 740 + 741 + If unsure, say N. 742 + 743 + The Operation Panel is a controller with some buttons and an LCD 744 + display that allows someone with physical access to the system to 745 + perform various administrative tasks. This driver only supports the part 746 + of the controller that sends commands to the system. 747 + 748 + To compile this driver as a module, choose M here: the module will be 749 + called ibm-panel. 750 + 733 751 config INPUT_IMS_PCU 734 752 tristate "IMS Passenger Control Unit driver" 735 753 depends on USB ··· 908 890 909 891 To compile this driver as a module, choose M here. The module will 910 892 be called sc27xx_vibra. 893 + 894 + config INPUT_RT5120_PWRKEY 895 + tristate "RT5120 PMIC power key support" 896 + depends on MFD_RT5120 || COMPILE_TEST 897 + help 898 + This enables support for RT5120 PMIC power key driver. 899 + 900 + To compile this driver as a module, choose M here. the module will 901 + be called rt5120-pwrkey. 911 902 912 903 config INPUT_STPMIC1_ONKEY 913 904 tristate "STPMIC1 PMIC Onkey support"
+2
drivers/input/misc/Makefile
··· 41 41 obj-$(CONFIG_INPUT_GPIO_VIBRA) += gpio-vibra.o 42 42 obj-$(CONFIG_INPUT_HISI_POWERKEY) += hisi_powerkey.o 43 43 obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o 44 + obj-$(CONFIG_INPUT_IBM_PANEL) += ibm-panel.o 44 45 obj-$(CONFIG_INPUT_IMS_PCU) += ims-pcu.o 45 46 obj-$(CONFIG_INPUT_IQS269A) += iqs269a.o 46 47 obj-$(CONFIG_INPUT_IQS626A) += iqs626a.o ··· 70 69 obj-$(CONFIG_INPUT_RB532_BUTTON) += rb532_button.o 71 70 obj-$(CONFIG_INPUT_REGULATOR_HAPTIC) += regulator-haptic.o 72 71 obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o 72 + obj-$(CONFIG_INPUT_RT5120_PWRKEY) += rt5120-pwrkey.o 73 73 obj-$(CONFIG_INPUT_AXP20X_PEK) += axp20x-pek.o 74 74 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER) += rotary_encoder.o 75 75 obj-$(CONFIG_INPUT_RK805_PWRKEY) += rk805-pwrkey.o
+200
drivers/input/misc/ibm-panel.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* 3 + * Copyright (C) IBM Corporation 2020 4 + */ 5 + 6 + #include <linux/i2c.h> 7 + #include <linux/init.h> 8 + #include <linux/input.h> 9 + #include <linux/kernel.h> 10 + #include <linux/limits.h> 11 + #include <linux/module.h> 12 + #include <linux/of.h> 13 + #include <linux/spinlock.h> 14 + 15 + #define DEVICE_NAME "ibm-panel" 16 + #define PANEL_KEYCODES_COUNT 3 17 + 18 + struct ibm_panel { 19 + u8 idx; 20 + u8 command[11]; 21 + u32 keycodes[PANEL_KEYCODES_COUNT]; 22 + spinlock_t lock; /* protects writes to idx and command */ 23 + struct input_dev *input; 24 + }; 25 + 26 + static u8 ibm_panel_calculate_checksum(struct ibm_panel *panel) 27 + { 28 + u8 chksum; 29 + u16 sum = 0; 30 + unsigned int i; 31 + 32 + for (i = 0; i < sizeof(panel->command) - 1; ++i) { 33 + sum += panel->command[i]; 34 + if (sum & 0xff00) { 35 + sum &= 0xff; 36 + sum++; 37 + } 38 + } 39 + 40 + chksum = sum & 0xff; 41 + chksum = ~chksum; 42 + chksum++; 43 + 44 + return chksum; 45 + } 46 + 47 + static void ibm_panel_process_command(struct ibm_panel *panel) 48 + { 49 + u8 button; 50 + u8 chksum; 51 + 52 + if (panel->command[0] != 0xff && panel->command[1] != 0xf0) { 53 + dev_dbg(&panel->input->dev, "command invalid: %02x %02x\n", 54 + panel->command[0], panel->command[1]); 55 + return; 56 + } 57 + 58 + chksum = ibm_panel_calculate_checksum(panel); 59 + if (chksum != panel->command[sizeof(panel->command) - 1]) { 60 + dev_dbg(&panel->input->dev, 61 + "command failed checksum: %u != %u\n", chksum, 62 + panel->command[sizeof(panel->command) - 1]); 63 + return; 64 + } 65 + 66 + button = panel->command[2] & 0xf; 67 + if (button < PANEL_KEYCODES_COUNT) { 68 + input_report_key(panel->input, panel->keycodes[button], 69 + !(panel->command[2] & 0x80)); 70 + input_sync(panel->input); 71 + } else { 72 + dev_dbg(&panel->input->dev, "unknown button %u\n", 73 + button); 74 + } 75 + } 76 + 77 + static int ibm_panel_i2c_slave_cb(struct i2c_client *client, 78 + enum i2c_slave_event event, u8 *val) 79 + { 80 + unsigned long flags; 81 + struct ibm_panel *panel = i2c_get_clientdata(client); 82 + 83 + dev_dbg(&panel->input->dev, "event: %u data: %02x\n", event, *val); 84 + 85 + spin_lock_irqsave(&panel->lock, flags); 86 + 87 + switch (event) { 88 + case I2C_SLAVE_STOP: 89 + if (panel->idx == sizeof(panel->command)) 90 + ibm_panel_process_command(panel); 91 + else 92 + dev_dbg(&panel->input->dev, 93 + "command incorrect size %u\n", panel->idx); 94 + fallthrough; 95 + case I2C_SLAVE_WRITE_REQUESTED: 96 + panel->idx = 0; 97 + break; 98 + case I2C_SLAVE_WRITE_RECEIVED: 99 + if (panel->idx < sizeof(panel->command)) 100 + panel->command[panel->idx++] = *val; 101 + else 102 + /* 103 + * The command is too long and therefore invalid, so set the index 104 + * to it's largest possible value. When a STOP is finally received, 105 + * the command will be rejected upon processing. 106 + */ 107 + panel->idx = U8_MAX; 108 + break; 109 + case I2C_SLAVE_READ_REQUESTED: 110 + case I2C_SLAVE_READ_PROCESSED: 111 + *val = 0xff; 112 + break; 113 + default: 114 + break; 115 + } 116 + 117 + spin_unlock_irqrestore(&panel->lock, flags); 118 + 119 + return 0; 120 + } 121 + 122 + static int ibm_panel_probe(struct i2c_client *client, 123 + const struct i2c_device_id *id) 124 + { 125 + struct ibm_panel *panel; 126 + int i; 127 + int error; 128 + 129 + panel = devm_kzalloc(&client->dev, sizeof(*panel), GFP_KERNEL); 130 + if (!panel) 131 + return -ENOMEM; 132 + 133 + spin_lock_init(&panel->lock); 134 + 135 + panel->input = devm_input_allocate_device(&client->dev); 136 + if (!panel->input) 137 + return -ENOMEM; 138 + 139 + panel->input->name = client->name; 140 + panel->input->id.bustype = BUS_I2C; 141 + 142 + error = device_property_read_u32_array(&client->dev, 143 + "linux,keycodes", 144 + panel->keycodes, 145 + PANEL_KEYCODES_COUNT); 146 + if (error) { 147 + /* 148 + * Use gamepad buttons as defaults for compatibility with 149 + * existing applications. 150 + */ 151 + panel->keycodes[0] = BTN_NORTH; 152 + panel->keycodes[1] = BTN_SOUTH; 153 + panel->keycodes[2] = BTN_SELECT; 154 + } 155 + 156 + for (i = 0; i < PANEL_KEYCODES_COUNT; ++i) 157 + input_set_capability(panel->input, EV_KEY, panel->keycodes[i]); 158 + 159 + error = input_register_device(panel->input); 160 + if (error) { 161 + dev_err(&client->dev, 162 + "Failed to register input device: %d\n", error); 163 + return error; 164 + } 165 + 166 + i2c_set_clientdata(client, panel); 167 + error = i2c_slave_register(client, ibm_panel_i2c_slave_cb); 168 + if (error) { 169 + dev_err(&client->dev, 170 + "Failed to register as i2c slave: %d\n", error); 171 + return error; 172 + } 173 + 174 + return 0; 175 + } 176 + 177 + static void ibm_panel_remove(struct i2c_client *client) 178 + { 179 + i2c_slave_unregister(client); 180 + } 181 + 182 + static const struct of_device_id ibm_panel_match[] = { 183 + { .compatible = "ibm,op-panel" }, 184 + { } 185 + }; 186 + MODULE_DEVICE_TABLE(of, ibm_panel_match); 187 + 188 + static struct i2c_driver ibm_panel_driver = { 189 + .driver = { 190 + .name = DEVICE_NAME, 191 + .of_match_table = ibm_panel_match, 192 + }, 193 + .probe = ibm_panel_probe, 194 + .remove = ibm_panel_remove, 195 + }; 196 + module_i2c_driver(ibm_panel_driver); 197 + 198 + MODULE_AUTHOR("Eddie James <eajames@linux.ibm.com>"); 199 + MODULE_DESCRIPTION("IBM Operation Panel Driver"); 200 + MODULE_LICENSE("GPL");
+1 -1
drivers/input/misc/ims-pcu.c
··· 744 744 error = ims_pcu_execute_command(pcu, JUMP_TO_BTLDR, NULL, 0); 745 745 if (error) { 746 746 dev_err(pcu->dev, 747 - "Failure when sending JUMP TO BOOLTLOADER command, error: %d\n", 747 + "Failure when sending JUMP TO BOOTLOADER command, error: %d\n", 748 748 error); 749 749 return error; 750 750 }
+10 -6
drivers/input/misc/iqs7222.c
··· 1077 1077 1078 1078 static int iqs7222_force_comms(struct iqs7222_private *iqs7222) 1079 1079 { 1080 - u8 msg_buf[] = { 0xFF, 0x00, }; 1080 + u8 msg_buf[] = { 0xFF, }; 1081 1081 int ret; 1082 1082 1083 1083 /* ··· 1771 1771 if (!chan_node) 1772 1772 return 0; 1773 1773 1774 - if (dev_desc->allow_offset) { 1775 - sys_setup[dev_desc->allow_offset] |= BIT(chan_index); 1776 - if (fwnode_property_present(chan_node, "azoteq,ulp-allow")) 1777 - sys_setup[dev_desc->allow_offset] &= ~BIT(chan_index); 1778 - } 1774 + if (dev_desc->allow_offset && 1775 + fwnode_property_present(chan_node, "azoteq,ulp-allow")) 1776 + sys_setup[dev_desc->allow_offset] &= ~BIT(chan_index); 1779 1777 1780 1778 chan_setup[0] |= IQS7222_CHAN_SETUP_0_CHAN_EN; 1781 1779 ··· 2204 2206 u16 *sys_setup = iqs7222->sys_setup; 2205 2207 int error, i; 2206 2208 2209 + if (dev_desc->allow_offset) 2210 + sys_setup[dev_desc->allow_offset] = U16_MAX; 2211 + 2207 2212 if (dev_desc->event_offset) 2208 2213 sys_setup[dev_desc->event_offset] = IQS7222_EVENT_MASK_ATI; 2209 2214 ··· 2326 2325 */ 2327 2326 int k = 2 + j * (num_chan > 16 ? 2 : 1); 2328 2327 u16 state = le16_to_cpu(status[k + i / 16]); 2328 + 2329 + if (!iqs7222->kp_type[i][j]) 2330 + continue; 2329 2331 2330 2332 input_event(iqs7222->keypad, 2331 2333 iqs7222->kp_type[i][j],
+1 -1
drivers/input/misc/keyspan_remote.c
··· 485 485 } 486 486 487 487 if (udev->manufacturer) 488 - strlcpy(remote->name, udev->manufacturer, sizeof(remote->name)); 488 + strscpy(remote->name, udev->manufacturer, sizeof(remote->name)); 489 489 490 490 if (udev->product) { 491 491 if (udev->manufacturer)
+120
drivers/input/misc/rt5120-pwrkey.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (C) 2022 Richtek Technology Corp. 4 + * Author: ChiYuan Huang <cy_huang@richtek.com> 5 + */ 6 + 7 + #include <linux/bits.h> 8 + #include <linux/input.h> 9 + #include <linux/interrupt.h> 10 + #include <linux/kernel.h> 11 + #include <linux/module.h> 12 + #include <linux/mod_devicetable.h> 13 + #include <linux/platform_device.h> 14 + #include <linux/regmap.h> 15 + 16 + #define RT5120_REG_INTSTAT 0x1E 17 + #define RT5120_PWRKEYSTAT_MASK BIT(7) 18 + 19 + struct rt5120_priv { 20 + struct regmap *regmap; 21 + struct input_dev *input; 22 + }; 23 + 24 + static irqreturn_t rt5120_pwrkey_handler(int irq, void *devid) 25 + { 26 + struct rt5120_priv *priv = devid; 27 + unsigned int stat; 28 + int error; 29 + 30 + error = regmap_read(priv->regmap, RT5120_REG_INTSTAT, &stat); 31 + if (error) 32 + return IRQ_NONE; 33 + 34 + input_report_key(priv->input, KEY_POWER, 35 + !(stat & RT5120_PWRKEYSTAT_MASK)); 36 + input_sync(priv->input); 37 + 38 + return IRQ_HANDLED; 39 + } 40 + 41 + static int rt5120_pwrkey_probe(struct platform_device *pdev) 42 + { 43 + struct rt5120_priv *priv; 44 + struct device *dev = &pdev->dev; 45 + int press_irq, release_irq; 46 + int error; 47 + 48 + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 49 + if (!priv) 50 + return -ENOMEM; 51 + 52 + priv->regmap = dev_get_regmap(dev->parent, NULL); 53 + if (!priv->regmap) { 54 + dev_err(dev, "Failed to init regmap\n"); 55 + return -ENODEV; 56 + } 57 + 58 + press_irq = platform_get_irq_byname(pdev, "pwrkey-press"); 59 + if (press_irq < 0) 60 + return press_irq; 61 + 62 + release_irq = platform_get_irq_byname(pdev, "pwrkey-release"); 63 + if (release_irq < 0) 64 + return release_irq; 65 + 66 + /* Make input device be device resource managed */ 67 + priv->input = devm_input_allocate_device(dev); 68 + if (!priv->input) 69 + return -ENOMEM; 70 + 71 + priv->input->name = "rt5120_pwrkey"; 72 + priv->input->phys = "rt5120_pwrkey/input0"; 73 + priv->input->id.bustype = BUS_I2C; 74 + input_set_capability(priv->input, EV_KEY, KEY_POWER); 75 + 76 + error = input_register_device(priv->input); 77 + if (error) { 78 + dev_err(dev, "Failed to register input device: %d\n", error); 79 + return error; 80 + } 81 + 82 + error = devm_request_threaded_irq(dev, press_irq, 83 + NULL, rt5120_pwrkey_handler, 84 + 0, "pwrkey-press", priv); 85 + if (error) { 86 + dev_err(dev, 87 + "Failed to register pwrkey press irq: %d\n", error); 88 + return error; 89 + } 90 + 91 + error = devm_request_threaded_irq(dev, release_irq, 92 + NULL, rt5120_pwrkey_handler, 93 + 0, "pwrkey-release", priv); 94 + if (error) { 95 + dev_err(dev, 96 + "Failed to register pwrkey release irq: %d\n", error); 97 + return error; 98 + } 99 + 100 + return 0; 101 + } 102 + 103 + static const struct of_device_id r5120_pwrkey_match_table[] = { 104 + { .compatible = "richtek,rt5120-pwrkey" }, 105 + {} 106 + }; 107 + MODULE_DEVICE_TABLE(of, r5120_pwrkey_match_table); 108 + 109 + static struct platform_driver rt5120_pwrkey_driver = { 110 + .driver = { 111 + .name = "rt5120-pwrkey", 112 + .of_match_table = r5120_pwrkey_match_table, 113 + }, 114 + .probe = rt5120_pwrkey_probe, 115 + }; 116 + module_platform_driver(rt5120_pwrkey_driver); 117 + 118 + MODULE_AUTHOR("ChiYuan Huang <cy_huang@richtek.com>"); 119 + MODULE_DESCRIPTION("Richtek RT5120 power key driver"); 120 + MODULE_LICENSE("GPL");
+1
drivers/input/misc/twl4030-pwrbutton.c
··· 26 26 #include <linux/errno.h> 27 27 #include <linux/input.h> 28 28 #include <linux/interrupt.h> 29 + #include <linux/of.h> 29 30 #include <linux/platform_device.h> 30 31 #include <linux/mfd/twl.h> 31 32
+4 -9
drivers/input/misc/twl4030-vibra.c
··· 163 163 static SIMPLE_DEV_PM_OPS(twl4030_vibra_pm_ops, 164 164 twl4030_vibra_suspend, twl4030_vibra_resume); 165 165 166 - static bool twl4030_vibra_check_coexist(struct twl4030_vibra_data *pdata, 167 - struct device_node *parent) 166 + static bool twl4030_vibra_check_coexist(struct device_node *parent) 168 167 { 169 168 struct device_node *node; 170 - 171 - if (pdata && pdata->coexist) 172 - return true; 173 169 174 170 node = of_get_child_by_name(parent, "codec"); 175 171 if (node) { ··· 178 182 179 183 static int twl4030_vibra_probe(struct platform_device *pdev) 180 184 { 181 - struct twl4030_vibra_data *pdata = dev_get_platdata(&pdev->dev); 182 185 struct device_node *twl4030_core_node = pdev->dev.parent->of_node; 183 186 struct vibra_info *info; 184 187 int ret; 185 188 186 - if (!pdata && !twl4030_core_node) { 187 - dev_dbg(&pdev->dev, "platform_data not available\n"); 189 + if (!twl4030_core_node) { 190 + dev_dbg(&pdev->dev, "twl4030 OF node is missing\n"); 188 191 return -EINVAL; 189 192 } 190 193 ··· 192 197 return -ENOMEM; 193 198 194 199 info->dev = &pdev->dev; 195 - info->coexist = twl4030_vibra_check_coexist(pdata, twl4030_core_node); 200 + info->coexist = twl4030_vibra_check_coexist(twl4030_core_node); 196 201 INIT_WORK(&info->play_work, vibra_play_work); 197 202 198 203 info->input_dev = devm_input_allocate_device(&pdev->dev);
+1 -6
drivers/input/mouse/elan_i2c_core.c
··· 1311 1311 return error; 1312 1312 } 1313 1313 1314 - error = devm_device_add_groups(dev, elan_sysfs_groups); 1315 - if (error) { 1316 - dev_err(dev, "failed to create sysfs attributes: %d\n", error); 1317 - return error; 1318 - } 1319 - 1320 1314 error = input_register_device(data->input); 1321 1315 if (error) { 1322 1316 dev_err(dev, "failed to register input device: %d\n", error); ··· 1436 1442 .acpi_match_table = ACPI_PTR(elan_acpi_id), 1437 1443 .of_match_table = of_match_ptr(elan_of_match), 1438 1444 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1445 + .dev_groups = elan_sysfs_groups, 1439 1446 }, 1440 1447 .probe = elan_probe, 1441 1448 .id_table = elan_id,
+2 -2
drivers/input/mouse/hgpk.c
··· 884 884 885 885 /* 886 886 * We queue work instead of doing recalibration right here 887 - * to avoid adding locking to to hgpk_force_recalibrate() 887 + * to avoid adding locking to hgpk_force_recalibrate() 888 888 * since workqueue provides serialization. 889 889 */ 890 890 psmouse_queue_work(psmouse, &priv->recalib_wq, 0); ··· 1057 1057 strlen(hgpk_mode_name)); 1058 1058 if (hgpk_default_mode == HGPK_MODE_INVALID) { 1059 1059 hgpk_default_mode = HGPK_MODE_MOUSE; 1060 - strlcpy(hgpk_mode_name, hgpk_mode_names[HGPK_MODE_MOUSE], 1060 + strscpy(hgpk_mode_name, hgpk_mode_names[HGPK_MODE_MOUSE], 1061 1061 sizeof(hgpk_mode_name)); 1062 1062 } 1063 1063 }
-3
drivers/input/mouse/inport.c
··· 13 13 * Inport (ATI XL and Microsoft) busmouse driver for Linux 14 14 */ 15 15 16 - /* 17 - */ 18 - 19 16 #include <linux/module.h> 20 17 #include <linux/ioport.h> 21 18 #include <linux/init.h>
-3
drivers/input/mouse/logibm.c
··· 14 14 * Logitech Bus Mouse Driver for Linux 15 15 */ 16 16 17 - /* 18 - */ 19 - 20 17 #include <linux/module.h> 21 18 #include <linux/delay.h> 22 19 #include <linux/ioport.h>
-3
drivers/input/mouse/pc110pad.c
··· 10 10 * IBM PC110 touchpad driver for Linux 11 11 */ 12 12 13 - /* 14 - */ 15 - 16 13 #include <linux/module.h> 17 14 #include <linux/kernel.h> 18 15 #include <linux/errno.h>
+4 -18
drivers/input/mouse/psmouse-base.c
··· 94 94 (void *) offsetof(struct psmouse, resync_time), 95 95 psmouse_show_int_attr, psmouse_set_int_attr); 96 96 97 - static struct attribute *psmouse_attributes[] = { 97 + static struct attribute *psmouse_dev_attrs[] = { 98 98 &psmouse_attr_protocol.dattr.attr, 99 99 &psmouse_attr_rate.dattr.attr, 100 100 &psmouse_attr_resolution.dattr.attr, ··· 103 103 NULL 104 104 }; 105 105 106 - static const struct attribute_group psmouse_attribute_group = { 107 - .attrs = psmouse_attributes, 108 - }; 106 + ATTRIBUTE_GROUPS(psmouse_dev); 109 107 110 108 /* 111 109 * psmouse_mutex protects all operations changing state of mouse ··· 1479 1481 struct psmouse *psmouse = serio_get_drvdata(serio); 1480 1482 struct psmouse *parent = NULL; 1481 1483 1482 - sysfs_remove_group(&serio->dev.kobj, &psmouse_attribute_group); 1483 - 1484 1484 mutex_lock(&psmouse_mutex); 1485 1485 1486 1486 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); ··· 1643 1647 if (parent && parent->pt_activate) 1644 1648 parent->pt_activate(parent); 1645 1649 1646 - error = sysfs_create_group(&serio->dev.kobj, &psmouse_attribute_group); 1647 - if (error) 1648 - goto err_pt_deactivate; 1649 - 1650 1650 /* 1651 1651 * PS/2 devices having SMBus companions should stay disabled 1652 1652 * on PS/2 side, in order to have SMBus part operable. ··· 1658 1666 mutex_unlock(&psmouse_mutex); 1659 1667 return retval; 1660 1668 1661 - err_pt_deactivate: 1662 - if (parent && parent->pt_deactivate) 1663 - parent->pt_deactivate(parent); 1664 - if (input_dev) { 1665 - input_unregister_device(input_dev); 1666 - input_dev = NULL; /* so we don't try to free it below */ 1667 - } 1668 1669 err_protocol_disconnect: 1669 1670 if (psmouse->disconnect) 1670 1671 psmouse->disconnect(psmouse); ··· 1776 1791 1777 1792 static struct serio_driver psmouse_drv = { 1778 1793 .driver = { 1779 - .name = "psmouse", 1794 + .name = "psmouse", 1795 + .dev_groups = psmouse_dev_groups, 1780 1796 }, 1781 1797 .description = DRIVER_DESC, 1782 1798 .id_table = psmouse_serio_ids,
-3
drivers/input/mouse/sermouse.c
··· 7 7 * Serial mouse driver for Linux 8 8 */ 9 9 10 - /* 11 - */ 12 - 13 10 #include <linux/delay.h> 14 11 #include <linux/module.h> 15 12 #include <linux/slab.h>
+3 -2
drivers/input/mouse/synaptics.c
··· 182 182 "LEN0099", /* X1 Extreme Gen 1 / P1 Gen 1 */ 183 183 "LEN009b", /* T580 */ 184 184 "LEN0402", /* X1 Extreme Gen 2 / P1 Gen 2 */ 185 + "LEN040f", /* P1 Gen 3 */ 185 186 "LEN200f", /* T450s */ 186 187 "LEN2044", /* L470 */ 187 188 "LEN2054", /* E480 */ ··· 715 714 } 716 715 717 716 serio->id.type = SERIO_PS_PSTHRU; 718 - strlcpy(serio->name, "Synaptics pass-through", sizeof(serio->name)); 719 - strlcpy(serio->phys, "synaptics-pt/serio0", sizeof(serio->phys)); 717 + strscpy(serio->name, "Synaptics pass-through", sizeof(serio->name)); 718 + strscpy(serio->phys, "synaptics-pt/serio0", sizeof(serio->phys)); 720 719 serio->write = synaptics_pt_write; 721 720 serio->start = synaptics_pt_start; 722 721 serio->stop = synaptics_pt_stop;
+1 -1
drivers/input/mouse/synaptics_usb.c
··· 354 354 synusb->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 355 355 356 356 if (udev->manufacturer) 357 - strlcpy(synusb->name, udev->manufacturer, 357 + strscpy(synusb->name, udev->manufacturer, 358 358 sizeof(synusb->name)); 359 359 360 360 if (udev->product) {
+2 -5
drivers/input/mouse/vsxxxaa.c
··· 13 13 */ 14 14 15 15 /* 16 - */ 17 - 18 - /* 19 16 * Building an adaptor to DE9 / DB25 RS232 20 17 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 21 18 * ··· 135 138 { 136 139 switch (mouse->type) { 137 140 case 0x02: 138 - strlcpy(mouse->name, "DEC VSXXX-AA/-GA mouse", 141 + strscpy(mouse->name, "DEC VSXXX-AA/-GA mouse", 139 142 sizeof(mouse->name)); 140 143 break; 141 144 142 145 case 0x04: 143 - strlcpy(mouse->name, "DEC VSXXX-AB digitizer", 146 + strscpy(mouse->name, "DEC VSXXX-AB digitizer", 144 147 sizeof(mouse->name)); 145 148 break; 146 149
+1 -1
drivers/input/rmi4/rmi_f03.c
··· 181 181 serio->close = rmi_f03_pt_close; 182 182 serio->port_data = f03; 183 183 184 - strlcpy(serio->name, "RMI4 PS/2 pass-through", sizeof(serio->name)); 184 + strscpy(serio->name, "RMI4 PS/2 pass-through", sizeof(serio->name)); 185 185 snprintf(serio->phys, sizeof(serio->phys), "%s/serio0", 186 186 dev_name(&f03->fn->dev)); 187 187 serio->dev.parent = &f03->fn->dev;
+16 -16
drivers/input/rmi4/rmi_f34.c
··· 114 114 complete(&f34->v5.cmd_done); 115 115 } else { 116 116 ret = rmi_read_block(f34->fn->rmi_dev, 117 - f34->fn->fd.data_base_addr + 118 - f34->v7.off.flash_status, 119 - &status, sizeof(status)); 120 - rmi_dbg(RMI_DEBUG_FN, &fn->dev, "%s: status: %#02x, ret: %d\n", 117 + f34->fn->fd.data_base_addr + 118 + V7_COMMAND_OFFSET, 119 + &status, sizeof(status)); 120 + rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "%s: cmd: %#02x, ret: %d\n", 121 121 __func__, status, ret); 122 122 123 - if (!ret && !(status & 0x1f)) 123 + if (!ret && status == CMD_V7_IDLE) 124 124 complete(&f34->v7.cmd_done); 125 125 } 126 126 ··· 321 321 f34 = dev_get_drvdata(&fn->dev); 322 322 323 323 if (f34->bl_version == 5) 324 - return scnprintf(buf, PAGE_SIZE, "%c%c\n", 325 - f34->bootloader_id[0], 326 - f34->bootloader_id[1]); 324 + return sysfs_emit(buf, "%c%c\n", 325 + f34->bootloader_id[0], 326 + f34->bootloader_id[1]); 327 327 else 328 - return scnprintf(buf, PAGE_SIZE, "V%d.%d\n", 329 - f34->bootloader_id[1], 330 - f34->bootloader_id[0]); 328 + return sysfs_emit(buf, "V%d.%d\n", 329 + f34->bootloader_id[1], 330 + f34->bootloader_id[0]); 331 331 } 332 332 333 333 return 0; ··· 346 346 if (fn) { 347 347 f34 = dev_get_drvdata(&fn->dev); 348 348 349 - return scnprintf(buf, PAGE_SIZE, "%s\n", f34->configuration_id); 349 + return sysfs_emit(buf, "%s\n", f34->configuration_id); 350 350 } 351 351 352 352 return 0; ··· 370 370 371 371 f34 = dev_get_drvdata(&data->f34_container->dev); 372 372 373 - if (f34->bl_version == 7) { 373 + if (f34->bl_version >= 7) { 374 374 if (data->pdt_props & HAS_BSR) { 375 375 dev_err(dev, "%s: LTS not supported\n", __func__); 376 376 return -ENODEV; ··· 382 382 } 383 383 384 384 /* Enter flash mode */ 385 - if (f34->bl_version == 7) 385 + if (f34->bl_version >= 7) 386 386 ret = rmi_f34v7_start_reflash(f34, fw); 387 387 else 388 388 ret = rmi_f34_enable_flash(f34); ··· 413 413 f34 = dev_get_drvdata(&data->f34_container->dev); 414 414 415 415 /* Perform firmware update */ 416 - if (f34->bl_version == 7) 416 + if (f34->bl_version >= 7) 417 417 ret = rmi_f34v7_do_reflash(f34, fw); 418 418 else 419 419 ret = rmi_f34_update_firmware(f34, fw); ··· 499 499 if (data->f34_container) 500 500 update_status = rmi_f34_status(data->f34_container); 501 501 502 - return scnprintf(buf, PAGE_SIZE, "%d\n", update_status); 502 + return sysfs_emit(buf, "%d\n", update_status); 503 503 } 504 504 505 505 static DEVICE_ATTR(update_fw_status, 0444,
-17
drivers/input/rmi4/rmi_f34.h
··· 222 222 struct physical_address phyaddr; 223 223 }; 224 224 225 - struct register_offset { 226 - u8 properties; 227 - u8 properties_2; 228 - u8 block_size; 229 - u8 block_count; 230 - u8 gc_block_count; 231 - u8 flash_status; 232 - u8 partition_id; 233 - u8 block_number; 234 - u8 transfer_length; 235 - u8 flash_cmd; 236 - u8 payload; 237 - }; 238 - 239 225 struct rmi_f34_firmware { 240 226 __le32 checksum; 241 227 u8 pad1[3]; ··· 248 262 struct f34v7_data { 249 263 bool has_display_cfg; 250 264 bool has_guest_code; 251 - bool force_update; 252 265 bool in_bl_mode; 253 266 u8 *read_config_buf; 254 267 size_t read_config_buf_size; ··· 261 276 u16 payload_length; 262 277 u8 partitions; 263 278 u16 partition_table_bytes; 264 - bool new_partition_table; 265 279 266 - struct register_offset off; 267 280 struct block_count blkcount; 268 281 struct physical_address phyaddr; 269 282 struct image_metadata img;
+73 -276
drivers/input/rmi4/rmi_f34v7.c
··· 25 25 int ret; 26 26 27 27 ret = rmi_read_block(f34->fn->rmi_dev, 28 - f34->fn->fd.data_base_addr + f34->v7.off.flash_status, 28 + f34->fn->fd.data_base_addr + V7_FLASH_STATUS_OFFSET, 29 29 &status, 30 30 sizeof(status)); 31 31 if (ret < 0) { ··· 43 43 } 44 44 45 45 ret = rmi_read_block(f34->fn->rmi_dev, 46 - f34->fn->fd.data_base_addr + f34->v7.off.flash_cmd, 46 + f34->fn->fd.data_base_addr + V7_COMMAND_OFFSET, 47 47 &command, 48 48 sizeof(command)); 49 49 if (ret < 0) { ··· 68 68 __func__); 69 69 return -ETIMEDOUT; 70 70 } 71 + 72 + return 0; 73 + } 74 + 75 + static int rmi_f34v7_check_command_status(struct f34_data *f34, int timeout_ms) 76 + { 77 + int ret; 78 + 79 + ret = rmi_f34v7_wait_for_idle(f34, timeout_ms); 80 + if (ret < 0) 81 + return ret; 82 + 83 + ret = rmi_f34v7_read_flash_status(f34); 84 + if (ret < 0) 85 + return ret; 86 + 87 + if (f34->v7.flash_status != 0x00) 88 + return -EIO; 71 89 72 90 return 0; 73 91 } ··· 140 122 data_1_5.payload[1] = f34->bootloader_id[1]; 141 123 142 124 ret = rmi_write_block(f34->fn->rmi_dev, 143 - base + f34->v7.off.partition_id, 125 + base + V7_PARTITION_ID_OFFSET, 144 126 &data_1_5, sizeof(data_1_5)); 145 127 if (ret < 0) { 146 128 dev_err(&f34->fn->dev, ··· 213 195 __func__, command); 214 196 215 197 ret = rmi_write_block(f34->fn->rmi_dev, 216 - base + f34->v7.off.flash_cmd, 198 + base + V7_COMMAND_OFFSET, 217 199 &command, sizeof(command)); 218 200 if (ret < 0) { 219 201 dev_err(&f34->fn->dev, "%s: Failed to write flash command\n", ··· 280 262 } 281 263 282 264 ret = rmi_write_block(f34->fn->rmi_dev, 283 - base + f34->v7.off.partition_id, 265 + base + V7_PARTITION_ID_OFFSET, 284 266 &partition, sizeof(partition)); 285 267 if (ret < 0) { 286 268 dev_err(&f34->fn->dev, "%s: Failed to write partition ID\n", ··· 308 290 return ret; 309 291 310 292 ret = rmi_write_block(f34->fn->rmi_dev, 311 - base + f34->v7.off.block_number, 293 + base + V7_BLOCK_NUMBER_OFFSET, 312 294 &block_number, sizeof(block_number)); 313 295 if (ret < 0) { 314 296 dev_err(&f34->fn->dev, "%s: Failed to write block number\n", ··· 319 301 put_unaligned_le16(f34->v7.flash_config_length, &length); 320 302 321 303 ret = rmi_write_block(f34->fn->rmi_dev, 322 - base + f34->v7.off.transfer_length, 304 + base + V7_TRANSFER_LENGTH_OFFSET, 323 305 &length, sizeof(length)); 324 306 if (ret < 0) { 325 307 dev_err(&f34->fn->dev, "%s: Failed to write transfer length\n", ··· 336 318 return ret; 337 319 } 338 320 321 + /* 322 + * rmi_f34v7_check_command_status() can't be used here, as this 323 + * function is called before IRQs are available 324 + */ 339 325 timeout = msecs_to_jiffies(F34_WRITE_WAIT_MS); 340 326 while (time_before(jiffies, timeout)) { 341 327 usleep_range(5000, 6000); ··· 352 330 } 353 331 354 332 ret = rmi_read_block(f34->fn->rmi_dev, 355 - base + f34->v7.off.payload, 333 + base + V7_PAYLOAD_OFFSET, 356 334 f34->v7.read_config_buf, 357 335 f34->v7.partition_table_bytes); 358 336 if (ret < 0) { ··· 526 504 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "%s: f34->v7.block_size = %d\n", 527 505 __func__, f34->v7.block_size); 528 506 529 - f34->v7.off.flash_status = V7_FLASH_STATUS_OFFSET; 530 - f34->v7.off.partition_id = V7_PARTITION_ID_OFFSET; 531 - f34->v7.off.block_number = V7_BLOCK_NUMBER_OFFSET; 532 - f34->v7.off.transfer_length = V7_TRANSFER_LENGTH_OFFSET; 533 - f34->v7.off.flash_cmd = V7_COMMAND_OFFSET; 534 - f34->v7.off.payload = V7_PAYLOAD_OFFSET; 535 - 536 507 f34->v7.has_display_cfg = query_1_7.partition_support[1] & HAS_DISP_CFG; 537 508 f34->v7.has_guest_code = 538 509 query_1_7.partition_support[1] & HAS_GUEST_CODE; ··· 586 571 return 0; 587 572 } 588 573 589 - static int rmi_f34v7_check_ui_firmware_size(struct f34_data *f34) 590 - { 591 - u16 block_count; 592 - 593 - block_count = f34->v7.img.ui_firmware.size / f34->v7.block_size; 594 - f34->update_size += block_count; 595 - 596 - if (block_count != f34->v7.blkcount.ui_firmware) { 597 - dev_err(&f34->fn->dev, 598 - "UI firmware size mismatch: %d != %d\n", 599 - block_count, f34->v7.blkcount.ui_firmware); 600 - return -EINVAL; 601 - } 602 - 603 - return 0; 604 - } 605 - 606 - static int rmi_f34v7_check_ui_config_size(struct f34_data *f34) 607 - { 608 - u16 block_count; 609 - 610 - block_count = f34->v7.img.ui_config.size / f34->v7.block_size; 611 - f34->update_size += block_count; 612 - 613 - if (block_count != f34->v7.blkcount.ui_config) { 614 - dev_err(&f34->fn->dev, "UI config size mismatch\n"); 615 - return -EINVAL; 616 - } 617 - 618 - return 0; 619 - } 620 - 621 - static int rmi_f34v7_check_dp_config_size(struct f34_data *f34) 622 - { 623 - u16 block_count; 624 - 625 - block_count = f34->v7.img.dp_config.size / f34->v7.block_size; 626 - f34->update_size += block_count; 627 - 628 - if (block_count != f34->v7.blkcount.dp_config) { 629 - dev_err(&f34->fn->dev, "Display config size mismatch\n"); 630 - return -EINVAL; 631 - } 632 - 633 - return 0; 634 - } 635 - 636 - static int rmi_f34v7_check_guest_code_size(struct f34_data *f34) 637 - { 638 - u16 block_count; 639 - 640 - block_count = f34->v7.img.guest_code.size / f34->v7.block_size; 641 - f34->update_size += block_count; 642 - 643 - if (block_count != f34->v7.blkcount.guest_code) { 644 - dev_err(&f34->fn->dev, "Guest code size mismatch\n"); 645 - return -EINVAL; 646 - } 647 - 648 - return 0; 649 - } 650 - 651 574 static int rmi_f34v7_check_bl_config_size(struct f34_data *f34) 652 575 { 653 576 u16 block_count; ··· 601 648 return 0; 602 649 } 603 650 604 - static int rmi_f34v7_erase_config(struct f34_data *f34) 605 - { 606 - int ret; 607 - 608 - dev_info(&f34->fn->dev, "Erasing config...\n"); 609 - 610 - init_completion(&f34->v7.cmd_done); 611 - 612 - switch (f34->v7.config_area) { 613 - case v7_UI_CONFIG_AREA: 614 - ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_UI_CONFIG); 615 - if (ret < 0) 616 - return ret; 617 - break; 618 - case v7_DP_CONFIG_AREA: 619 - ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_DISP_CONFIG); 620 - if (ret < 0) 621 - return ret; 622 - break; 623 - case v7_BL_CONFIG_AREA: 624 - ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_BL_CONFIG); 625 - if (ret < 0) 626 - return ret; 627 - break; 628 - } 629 - 630 - ret = rmi_f34v7_wait_for_idle(f34, F34_ERASE_WAIT_MS); 631 - if (ret < 0) 632 - return ret; 633 - 634 - return 0; 635 - } 636 - 637 - static int rmi_f34v7_erase_guest_code(struct f34_data *f34) 638 - { 639 - int ret; 640 - 641 - dev_info(&f34->fn->dev, "Erasing guest code...\n"); 642 - 643 - init_completion(&f34->v7.cmd_done); 644 - 645 - ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_GUEST_CODE); 646 - if (ret < 0) 647 - return ret; 648 - 649 - ret = rmi_f34v7_wait_for_idle(f34, F34_ERASE_WAIT_MS); 650 - if (ret < 0) 651 - return ret; 652 - 653 - return 0; 654 - } 655 - 656 651 static int rmi_f34v7_erase_all(struct f34_data *f34) 657 652 { 658 653 int ret; ··· 609 708 610 709 init_completion(&f34->v7.cmd_done); 611 710 612 - ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_UI_FIRMWARE); 711 + ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_ALL); 613 712 if (ret < 0) 614 713 return ret; 615 714 616 - ret = rmi_f34v7_wait_for_idle(f34, F34_ERASE_WAIT_MS); 715 + ret = rmi_f34v7_check_command_status(f34, F34_ERASE_WAIT_MS); 617 716 if (ret < 0) 618 717 return ret; 619 - 620 - f34->v7.config_area = v7_UI_CONFIG_AREA; 621 - ret = rmi_f34v7_erase_config(f34); 622 - if (ret < 0) 623 - return ret; 624 - 625 - if (f34->v7.has_display_cfg) { 626 - f34->v7.config_area = v7_DP_CONFIG_AREA; 627 - ret = rmi_f34v7_erase_config(f34); 628 - if (ret < 0) 629 - return ret; 630 - } 631 - 632 - if (f34->v7.new_partition_table && f34->v7.has_guest_code) { 633 - ret = rmi_f34v7_erase_guest_code(f34); 634 - if (ret < 0) 635 - return ret; 636 - } 637 718 638 719 return 0; 639 720 } ··· 639 756 return ret; 640 757 641 758 ret = rmi_write_block(f34->fn->rmi_dev, 642 - base + f34->v7.off.block_number, 759 + base + V7_BLOCK_NUMBER_OFFSET, 643 760 &block_number, sizeof(block_number)); 644 761 if (ret < 0) { 645 762 dev_err(&f34->fn->dev, "%s: Failed to write block number\n", ··· 655 772 put_unaligned_le16(transfer, &length); 656 773 657 774 ret = rmi_write_block(f34->fn->rmi_dev, 658 - base + f34->v7.off.transfer_length, 775 + base + V7_TRANSFER_LENGTH_OFFSET, 659 776 &length, sizeof(length)); 660 777 if (ret < 0) { 661 778 dev_err(&f34->fn->dev, ··· 670 787 if (ret < 0) 671 788 return ret; 672 789 673 - ret = rmi_f34v7_wait_for_idle(f34, F34_ENABLE_WAIT_MS); 790 + ret = rmi_f34v7_check_command_status(f34, F34_ENABLE_WAIT_MS); 674 791 if (ret < 0) 675 792 return ret; 676 793 677 794 ret = rmi_read_block(f34->fn->rmi_dev, 678 - base + f34->v7.off.payload, 795 + base + V7_PAYLOAD_OFFSET, 679 796 &f34->v7.read_config_buf[index], 680 797 transfer * f34->v7.block_size); 681 798 if (ret < 0) { ··· 711 828 return ret; 712 829 713 830 ret = rmi_write_block(f34->fn->rmi_dev, 714 - base + f34->v7.off.block_number, 831 + base + V7_BLOCK_NUMBER_OFFSET, 715 832 &block_number, sizeof(block_number)); 716 833 if (ret < 0) { 717 834 dev_err(&f34->fn->dev, "%s: Failed to write block number\n", ··· 731 848 init_completion(&f34->v7.cmd_done); 732 849 733 850 ret = rmi_write_block(f34->fn->rmi_dev, 734 - base + f34->v7.off.transfer_length, 851 + base + V7_TRANSFER_LENGTH_OFFSET, 735 852 &length, sizeof(length)); 736 853 if (ret < 0) { 737 854 dev_err(&f34->fn->dev, ··· 745 862 return ret; 746 863 747 864 ret = rmi_write_block(f34->fn->rmi_dev, 748 - base + f34->v7.off.payload, 865 + base + V7_PAYLOAD_OFFSET, 749 866 block_ptr, transfer * f34->v7.block_size); 750 867 if (ret < 0) { 751 868 dev_err(&f34->fn->dev, ··· 754 871 return ret; 755 872 } 756 873 757 - ret = rmi_f34v7_wait_for_idle(f34, F34_ENABLE_WAIT_MS); 874 + ret = rmi_f34v7_check_command_status(f34, F34_ENABLE_WAIT_MS); 758 875 if (ret < 0) 759 876 return ret; 760 877 ··· 820 937 821 938 init_completion(&f34->v7.cmd_done); 822 939 823 - ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_FLASH_CONFIG); 824 - if (ret < 0) 825 - return ret; 826 - 827 - rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, 828 - "%s: Erase flash config command written\n", __func__); 829 - 830 - ret = rmi_f34v7_wait_for_idle(f34, F34_WRITE_WAIT_MS); 831 - if (ret < 0) 832 - return ret; 833 - 834 940 ret = rmi_f34v7_write_config(f34); 835 941 if (ret < 0) 836 942 return ret; ··· 849 977 if (ret < 0) 850 978 return ret; 851 979 852 - ret = rmi_f34v7_erase_config(f34); 853 - if (ret < 0) 854 - return ret; 855 - 856 980 ret = rmi_f34v7_write_flash_config(f34); 857 981 if (ret < 0) 858 982 return ret; ··· 873 1005 874 1006 return rmi_f34v7_write_f34v7_blocks(f34, f34->v7.img.ui_firmware.data, 875 1007 blk_count, v7_CMD_WRITE_FW); 876 - } 877 - 878 - static void rmi_f34v7_compare_partition_tables(struct f34_data *f34) 879 - { 880 - if (f34->v7.phyaddr.ui_firmware != f34->v7.img.phyaddr.ui_firmware) { 881 - f34->v7.new_partition_table = true; 882 - return; 883 - } 884 - 885 - if (f34->v7.phyaddr.ui_config != f34->v7.img.phyaddr.ui_config) { 886 - f34->v7.new_partition_table = true; 887 - return; 888 - } 889 - 890 - if (f34->v7.has_display_cfg && 891 - f34->v7.phyaddr.dp_config != f34->v7.img.phyaddr.dp_config) { 892 - f34->v7.new_partition_table = true; 893 - return; 894 - } 895 - 896 - if (f34->v7.has_guest_code && 897 - f34->v7.phyaddr.guest_code != f34->v7.img.phyaddr.guest_code) { 898 - f34->v7.new_partition_table = true; 899 - return; 900 - } 901 - 902 - f34->v7.new_partition_table = false; 903 1008 } 904 1009 905 1010 static void rmi_f34v7_parse_img_header_10_bl_container(struct f34_data *f34, ··· 1021 1180 rmi_f34v7_parse_partition_table(f34, f34->v7.img.fl_config.data, 1022 1181 &f34->v7.img.blkcount, &f34->v7.img.phyaddr); 1023 1182 1024 - rmi_f34v7_compare_partition_tables(f34); 1025 - 1026 1183 return 0; 1027 1184 } 1028 1185 ··· 1039 1200 1040 1201 ret = rmi_f34v7_parse_image_info(f34); 1041 1202 if (ret < 0) 1042 - goto fail; 1203 + return ret; 1043 1204 1044 - if (!f34->v7.new_partition_table) { 1045 - ret = rmi_f34v7_check_ui_firmware_size(f34); 1046 - if (ret < 0) 1047 - goto fail; 1048 - 1049 - ret = rmi_f34v7_check_ui_config_size(f34); 1050 - if (ret < 0) 1051 - goto fail; 1052 - 1053 - if (f34->v7.has_display_cfg && 1054 - f34->v7.img.contains_display_cfg) { 1055 - ret = rmi_f34v7_check_dp_config_size(f34); 1056 - if (ret < 0) 1057 - goto fail; 1058 - } 1059 - 1060 - if (f34->v7.has_guest_code && f34->v7.img.contains_guest_code) { 1061 - ret = rmi_f34v7_check_guest_code_size(f34); 1062 - if (ret < 0) 1063 - goto fail; 1064 - } 1065 - } else { 1066 - ret = rmi_f34v7_check_bl_config_size(f34); 1067 - if (ret < 0) 1068 - goto fail; 1069 - } 1205 + ret = rmi_f34v7_check_bl_config_size(f34); 1206 + if (ret < 0) 1207 + return ret; 1070 1208 1071 1209 ret = rmi_f34v7_erase_all(f34); 1072 1210 if (ret < 0) 1073 - goto fail; 1211 + return ret; 1074 1212 1075 - if (f34->v7.new_partition_table) { 1076 - ret = rmi_f34v7_write_partition_table(f34); 1077 - if (ret < 0) 1078 - goto fail; 1079 - dev_info(&f34->fn->dev, "%s: Partition table programmed\n", 1080 - __func__); 1081 - } 1213 + ret = rmi_f34v7_write_partition_table(f34); 1214 + if (ret < 0) 1215 + return ret; 1216 + dev_info(&f34->fn->dev, "%s: Partition table programmed\n", __func__); 1217 + 1218 + /* 1219 + * Reset to reload partition table - as the previous firmware has been 1220 + * erased, we remain in bootloader mode. 1221 + */ 1222 + ret = rmi_scan_pdt(f34->fn->rmi_dev, NULL, rmi_initial_reset); 1223 + if (ret < 0) 1224 + dev_warn(&f34->fn->dev, "RMI reset failed!\n"); 1082 1225 1083 1226 dev_info(&f34->fn->dev, "Writing firmware (%d bytes)...\n", 1084 1227 f34->v7.img.ui_firmware.size); 1085 1228 1086 1229 ret = rmi_f34v7_write_firmware(f34); 1087 1230 if (ret < 0) 1088 - goto fail; 1231 + return ret; 1089 1232 1090 1233 dev_info(&f34->fn->dev, "Writing config (%d bytes)...\n", 1091 1234 f34->v7.img.ui_config.size); ··· 1075 1254 f34->v7.config_area = v7_UI_CONFIG_AREA; 1076 1255 ret = rmi_f34v7_write_ui_config(f34); 1077 1256 if (ret < 0) 1078 - goto fail; 1257 + return ret; 1079 1258 1080 1259 if (f34->v7.has_display_cfg && f34->v7.img.contains_display_cfg) { 1081 1260 dev_info(&f34->fn->dev, "Writing display config...\n"); 1082 1261 1083 1262 ret = rmi_f34v7_write_dp_config(f34); 1084 1263 if (ret < 0) 1085 - goto fail; 1264 + return ret; 1086 1265 } 1087 1266 1088 - if (f34->v7.new_partition_table) { 1089 - if (f34->v7.has_guest_code && f34->v7.img.contains_guest_code) { 1090 - dev_info(&f34->fn->dev, "Writing guest code...\n"); 1267 + if (f34->v7.has_guest_code && f34->v7.img.contains_guest_code) { 1268 + dev_info(&f34->fn->dev, "Writing guest code...\n"); 1091 1269 1092 - ret = rmi_f34v7_write_guest_code(f34); 1093 - if (ret < 0) 1094 - goto fail; 1095 - } 1270 + ret = rmi_f34v7_write_guest_code(f34); 1271 + if (ret < 0) 1272 + return ret; 1096 1273 } 1097 1274 1098 - fail: 1099 - return ret; 1275 + return 0; 1100 1276 } 1101 1277 1102 1278 static int rmi_f34v7_enter_flash_prog(struct f34_data *f34) ··· 1106 1288 if (ret < 0) 1107 1289 return ret; 1108 1290 1109 - if (f34->v7.in_bl_mode) 1291 + if (f34->v7.in_bl_mode) { 1292 + dev_info(&f34->fn->dev, "%s: Device in bootloader mode\n", 1293 + __func__); 1110 1294 return 0; 1295 + } 1111 1296 1112 1297 init_completion(&f34->v7.cmd_done); 1113 1298 ··· 1118 1297 if (ret < 0) 1119 1298 return ret; 1120 1299 1121 - ret = rmi_f34v7_wait_for_idle(f34, F34_ENABLE_WAIT_MS); 1300 + ret = rmi_f34v7_check_command_status(f34, F34_ENABLE_WAIT_MS); 1122 1301 if (ret < 0) 1123 1302 return ret; 1124 1303 ··· 1129 1308 { 1130 1309 int ret = 0; 1131 1310 1132 - f34->fn->rmi_dev->driver->set_irq_bits(f34->fn->rmi_dev, f34->fn->irq_mask); 1133 - 1134 1311 f34->v7.config_area = v7_UI_CONFIG_AREA; 1135 1312 f34->v7.image = fw->data; 1136 1313 1137 1314 ret = rmi_f34v7_parse_image_info(f34); 1138 1315 if (ret < 0) 1139 - goto exit; 1140 - 1141 - if (!f34->v7.force_update && f34->v7.new_partition_table) { 1142 - dev_err(&f34->fn->dev, "%s: Partition table mismatch\n", 1143 - __func__); 1144 - ret = -EINVAL; 1145 - goto exit; 1146 - } 1316 + return ret; 1147 1317 1148 1318 dev_info(&f34->fn->dev, "Firmware image OK\n"); 1149 1319 1150 - ret = rmi_f34v7_read_flash_status(f34); 1151 - if (ret < 0) 1152 - goto exit; 1153 - 1154 - if (f34->v7.in_bl_mode) { 1155 - dev_info(&f34->fn->dev, "%s: Device in bootloader mode\n", 1156 - __func__); 1157 - } 1158 - 1159 - rmi_f34v7_enter_flash_prog(f34); 1160 - 1161 - return 0; 1162 - 1163 - exit: 1164 - return ret; 1320 + return rmi_f34v7_enter_flash_prog(f34); 1165 1321 } 1166 1322 1167 1323 int rmi_f34v7_probe(struct f34_data *f34) ··· 1182 1384 if (ret < 0) 1183 1385 return ret; 1184 1386 1185 - f34->v7.force_update = true; 1186 1387 return 0; 1187 1388 }
+4 -4
drivers/input/rmi4/rmi_f54.c
··· 390 390 { 391 391 struct f54_data *f54 = video_drvdata(file); 392 392 393 - strlcpy(cap->driver, F54_NAME, sizeof(cap->driver)); 394 - strlcpy(cap->card, SYNAPTICS_INPUT_DEVICE_NAME, sizeof(cap->card)); 393 + strscpy(cap->driver, F54_NAME, sizeof(cap->driver)); 394 + strscpy(cap->card, SYNAPTICS_INPUT_DEVICE_NAME, sizeof(cap->card)); 395 395 snprintf(cap->bus_info, sizeof(cap->bus_info), 396 396 "rmi4:%s", dev_name(&f54->fn->dev)); 397 397 ··· 410 410 411 411 i->type = V4L2_INPUT_TYPE_TOUCH; 412 412 413 - strlcpy(i->name, rmi_f54_report_type_names[reptype], sizeof(i->name)); 413 + strscpy(i->name, rmi_f54_report_type_names[reptype], sizeof(i->name)); 414 414 return 0; 415 415 } 416 416 ··· 696 696 rmi_f54_set_input(f54, 0); 697 697 698 698 /* register video device */ 699 - strlcpy(f54->v4l2.name, F54_NAME, sizeof(f54->v4l2.name)); 699 + strscpy(f54->v4l2.name, F54_NAME, sizeof(f54->v4l2.name)); 700 700 ret = v4l2_device_register(&fn->dev, &f54->v4l2); 701 701 if (ret) { 702 702 dev_err(&fn->dev, "Unable to register video dev.\n");
+2 -2
drivers/input/serio/altera_ps2.c
··· 110 110 serio->write = altera_ps2_write; 111 111 serio->open = altera_ps2_open; 112 112 serio->close = altera_ps2_close; 113 - strlcpy(serio->name, dev_name(&pdev->dev), sizeof(serio->name)); 114 - strlcpy(serio->phys, dev_name(&pdev->dev), sizeof(serio->phys)); 113 + strscpy(serio->name, dev_name(&pdev->dev), sizeof(serio->name)); 114 + strscpy(serio->phys, dev_name(&pdev->dev), sizeof(serio->phys)); 115 115 serio->port_data = ps2if; 116 116 serio->dev.parent = &pdev->dev; 117 117 ps2if->io = serio;
+2 -2
drivers/input/serio/ambakmi.c
··· 126 126 io->write = amba_kmi_write; 127 127 io->open = amba_kmi_open; 128 128 io->close = amba_kmi_close; 129 - strlcpy(io->name, dev_name(&dev->dev), sizeof(io->name)); 130 - strlcpy(io->phys, dev_name(&dev->dev), sizeof(io->phys)); 129 + strscpy(io->name, dev_name(&dev->dev), sizeof(io->name)); 130 + strscpy(io->phys, dev_name(&dev->dev), sizeof(io->phys)); 131 131 io->port_data = kmi; 132 132 io->dev.parent = &dev->dev; 133 133
+2 -2
drivers/input/serio/ams_delta_serio.c
··· 159 159 serio->id.type = SERIO_8042; 160 160 serio->open = ams_delta_serio_open; 161 161 serio->close = ams_delta_serio_close; 162 - strlcpy(serio->name, "AMS DELTA keyboard adapter", sizeof(serio->name)); 163 - strlcpy(serio->phys, dev_name(&pdev->dev), sizeof(serio->phys)); 162 + strscpy(serio->name, "AMS DELTA keyboard adapter", sizeof(serio->name)); 163 + strscpy(serio->phys, dev_name(&pdev->dev), sizeof(serio->phys)); 164 164 serio->dev.parent = &pdev->dev; 165 165 serio->port_data = priv; 166 166
+1 -1
drivers/input/serio/apbps2.c
··· 176 176 priv->io->close = apbps2_close; 177 177 priv->io->write = apbps2_write; 178 178 priv->io->port_data = priv; 179 - strlcpy(priv->io->name, "APBPS2 PS/2", sizeof(priv->io->name)); 179 + strscpy(priv->io->name, "APBPS2 PS/2", sizeof(priv->io->name)); 180 180 snprintf(priv->io->phys, sizeof(priv->io->phys), 181 181 "apbps2_%d", apbps2_idx++); 182 182
+1 -4
drivers/input/serio/ct82c710.c
··· 7 7 * 82C710 C&T mouse port chip driver for Linux 8 8 */ 9 9 10 - /* 11 - */ 12 - 13 10 #include <linux/delay.h> 14 11 #include <linux/module.h> 15 12 #include <linux/ioport.h> ··· 167 170 ct82c710_port->open = ct82c710_open; 168 171 ct82c710_port->close = ct82c710_close; 169 172 ct82c710_port->write = ct82c710_write; 170 - strlcpy(ct82c710_port->name, "C&T 82c710 mouse port", 173 + strscpy(ct82c710_port->name, "C&T 82c710 mouse port", 171 174 sizeof(ct82c710_port->name)); 172 175 snprintf(ct82c710_port->phys, sizeof(ct82c710_port->phys), 173 176 "isa%16llx/serio0", (unsigned long long)CT82C710_DATA);
+1 -1
drivers/input/serio/gscps2.c
··· 361 361 362 362 snprintf(serio->name, sizeof(serio->name), "gsc-ps2-%s", 363 363 (ps2port->id == GSC_ID_KEYBOARD) ? "keyboard" : "mouse"); 364 - strlcpy(serio->phys, dev_name(&dev->dev), sizeof(serio->phys)); 364 + strscpy(serio->phys, dev_name(&dev->dev), sizeof(serio->phys)); 365 365 serio->id.type = SERIO_8042; 366 366 serio->write = gscps2_write; 367 367 serio->open = gscps2_open;
+2 -2
drivers/input/serio/hyperv-keyboard.c
··· 334 334 hv_serio->dev.parent = &hv_dev->device; 335 335 hv_serio->id.type = SERIO_8042_XL; 336 336 hv_serio->port_data = kbd_dev; 337 - strlcpy(hv_serio->name, dev_name(&hv_dev->device), 337 + strscpy(hv_serio->name, dev_name(&hv_dev->device), 338 338 sizeof(hv_serio->name)); 339 - strlcpy(hv_serio->phys, dev_name(&hv_dev->device), 339 + strscpy(hv_serio->phys, dev_name(&hv_dev->device), 340 340 sizeof(hv_serio->phys)); 341 341 342 342 hv_serio->start = hv_kbd_start;
+19 -8
drivers/input/serio/i8042-sparcio.h
··· 3 3 #define _I8042_SPARCIO_H 4 4 5 5 #include <linux/of_device.h> 6 + #include <linux/types.h> 6 7 7 8 #include <asm/io.h> 8 9 #include <asm/oplib.h> ··· 104 103 .remove = sparc_i8042_remove, 105 104 }; 106 105 106 + static bool i8042_is_mr_coffee(void) 107 + { 108 + struct device_node *root; 109 + const char *name; 110 + bool is_mr_coffee; 111 + 112 + root = of_find_node_by_path("/"); 113 + 114 + name = of_get_property(root, "name", NULL); 115 + is_mr_coffee = name && !strcmp(name, "SUNW,JavaStation-1"); 116 + 117 + of_node_put(root); 118 + 119 + return is_mr_coffee; 120 + } 121 + 107 122 static int __init i8042_platform_init(void) 108 123 { 109 - struct device_node *root = of_find_node_by_path("/"); 110 - const char *name = of_get_property(root, "name", NULL); 111 - 112 - if (name && !strcmp(name, "SUNW,JavaStation-1")) { 124 + if (i8042_is_mr_coffee()) { 113 125 /* Hardcoded values for MrCoffee. */ 114 126 i8042_kbd_irq = i8042_aux_irq = 13 | 0x20; 115 127 kbd_iobase = ioremap(0x71300060, 8); ··· 150 136 151 137 static inline void i8042_platform_exit(void) 152 138 { 153 - struct device_node *root = of_find_node_by_path("/"); 154 - const char *name = of_get_property(root, "name", NULL); 155 - 156 - if (!name || strcmp(name, "SUNW,JavaStation-1")) 139 + if (!i8042_is_mr_coffee()) 157 140 platform_driver_unregister(&sparc_i8042_driver); 158 141 } 159 142
+12 -6
drivers/input/serio/i8042-x86ia64io.h drivers/input/serio/i8042-acpipnpio.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 - #ifndef _I8042_X86IA64IO_H 3 - #define _I8042_X86IA64IO_H 2 + #ifndef _I8042_ACPIPNPIO_H 3 + #define _I8042_ACPIPNPIO_H 4 4 5 + #include <linux/acpi.h> 5 6 6 7 #ifdef CONFIG_X86 7 8 #include <asm/x86_init.h> ··· 1301 1300 1302 1301 static void i8042_pnp_id_to_string(struct pnp_id *id, char *dst, int dst_size) 1303 1302 { 1304 - strlcpy(dst, "PNP:", dst_size); 1303 + strscpy(dst, "PNP:", dst_size); 1305 1304 1306 1305 while (id) { 1307 1306 strlcat(dst, " ", dst_size); ··· 1321 1320 if (pnp_irq_valid(dev,0)) 1322 1321 i8042_pnp_kbd_irq = pnp_irq(dev, 0); 1323 1322 1324 - strlcpy(i8042_pnp_kbd_name, did->id, sizeof(i8042_pnp_kbd_name)); 1323 + strscpy(i8042_pnp_kbd_name, did->id, sizeof(i8042_pnp_kbd_name)); 1325 1324 if (strlen(pnp_dev_name(dev))) { 1326 1325 strlcat(i8042_pnp_kbd_name, ":", sizeof(i8042_pnp_kbd_name)); 1327 1326 strlcat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name)); ··· 1348 1347 if (pnp_irq_valid(dev, 0)) 1349 1348 i8042_pnp_aux_irq = pnp_irq(dev, 0); 1350 1349 1351 - strlcpy(i8042_pnp_aux_name, did->id, sizeof(i8042_pnp_aux_name)); 1350 + strscpy(i8042_pnp_aux_name, did->id, sizeof(i8042_pnp_aux_name)); 1352 1351 if (strlen(pnp_dev_name(dev))) { 1353 1352 strlcat(i8042_pnp_aux_name, ":", sizeof(i8042_pnp_aux_name)); 1354 1353 strlcat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name)); ··· 1454 1453 return -ENODEV; 1455 1454 #else 1456 1455 pr_info("PNP: No PS/2 controller found.\n"); 1456 + #if defined(__loongarch__) 1457 + if (acpi_disabled == 0) 1458 + return -ENODEV; 1459 + #else 1457 1460 if (x86_platform.legacy.i8042 != 1458 1461 X86_LEGACY_I8042_EXPECTED_PRESENT) 1459 1462 return -ENODEV; 1463 + #endif 1460 1464 pr_info("Probing ports directly.\n"); 1461 1465 return 0; 1462 1466 #endif ··· 1671 1665 i8042_pnp_exit(); 1672 1666 } 1673 1667 1674 - #endif /* _I8042_X86IA64IO_H */ 1668 + #endif /* _I8042_ACPIPNPIO_H */
+7 -7
drivers/input/serio/i8042.c
··· 1341 1341 serio->ps2_cmd_mutex = &i8042_mutex; 1342 1342 serio->port_data = port; 1343 1343 serio->dev.parent = &i8042_platform_device->dev; 1344 - strlcpy(serio->name, "i8042 KBD port", sizeof(serio->name)); 1345 - strlcpy(serio->phys, I8042_KBD_PHYS_DESC, sizeof(serio->phys)); 1346 - strlcpy(serio->firmware_id, i8042_kbd_firmware_id, 1344 + strscpy(serio->name, "i8042 KBD port", sizeof(serio->name)); 1345 + strscpy(serio->phys, I8042_KBD_PHYS_DESC, sizeof(serio->phys)); 1346 + strscpy(serio->firmware_id, i8042_kbd_firmware_id, 1347 1347 sizeof(serio->firmware_id)); 1348 1348 set_primary_fwnode(&serio->dev, i8042_kbd_fwnode); 1349 1349 ··· 1371 1371 serio->port_data = port; 1372 1372 serio->dev.parent = &i8042_platform_device->dev; 1373 1373 if (idx < 0) { 1374 - strlcpy(serio->name, "i8042 AUX port", sizeof(serio->name)); 1375 - strlcpy(serio->phys, I8042_AUX_PHYS_DESC, sizeof(serio->phys)); 1376 - strlcpy(serio->firmware_id, i8042_aux_firmware_id, 1374 + strscpy(serio->name, "i8042 AUX port", sizeof(serio->name)); 1375 + strscpy(serio->phys, I8042_AUX_PHYS_DESC, sizeof(serio->phys)); 1376 + strscpy(serio->firmware_id, i8042_aux_firmware_id, 1377 1377 sizeof(serio->firmware_id)); 1378 1378 serio->close = i8042_port_close; 1379 1379 } else { 1380 1380 snprintf(serio->name, sizeof(serio->name), "i8042 AUX%d port", idx); 1381 1381 snprintf(serio->phys, sizeof(serio->phys), I8042_MUX_PHYS_DESC, idx + 1); 1382 - strlcpy(serio->firmware_id, i8042_aux_firmware_id, 1382 + strscpy(serio->firmware_id, i8042_aux_firmware_id, 1383 1383 sizeof(serio->firmware_id)); 1384 1384 } 1385 1385
+2 -2
drivers/input/serio/i8042.h
··· 19 19 #include "i8042-snirm.h" 20 20 #elif defined(CONFIG_SPARC) 21 21 #include "i8042-sparcio.h" 22 - #elif defined(CONFIG_X86) || defined(CONFIG_IA64) 23 - #include "i8042-x86ia64io.h" 22 + #elif defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_LOONGARCH) 23 + #include "i8042-acpipnpio.h" 24 24 #else 25 25 #include "i8042-io.h" 26 26 #endif
+4 -4
drivers/input/serio/olpc_apsp.c
··· 199 199 kb_serio->close = olpc_apsp_close; 200 200 kb_serio->port_data = priv; 201 201 kb_serio->dev.parent = &pdev->dev; 202 - strlcpy(kb_serio->name, "sp keyboard", sizeof(kb_serio->name)); 203 - strlcpy(kb_serio->phys, "sp/serio0", sizeof(kb_serio->phys)); 202 + strscpy(kb_serio->name, "sp keyboard", sizeof(kb_serio->name)); 203 + strscpy(kb_serio->phys, "sp/serio0", sizeof(kb_serio->phys)); 204 204 priv->kbio = kb_serio; 205 205 serio_register_port(kb_serio); 206 206 ··· 216 216 pad_serio->close = olpc_apsp_close; 217 217 pad_serio->port_data = priv; 218 218 pad_serio->dev.parent = &pdev->dev; 219 - strlcpy(pad_serio->name, "sp touchpad", sizeof(pad_serio->name)); 220 - strlcpy(pad_serio->phys, "sp/serio1", sizeof(pad_serio->phys)); 219 + strscpy(pad_serio->name, "sp touchpad", sizeof(pad_serio->name)); 220 + strscpy(pad_serio->phys, "sp/serio1", sizeof(pad_serio->phys)); 221 221 priv->padio = pad_serio; 222 222 serio_register_port(pad_serio); 223 223
+1 -1
drivers/input/serio/parkbd.c
··· 169 169 if (serio) { 170 170 serio->id.type = parkbd_mode; 171 171 serio->write = parkbd_write; 172 - strlcpy(serio->name, "PARKBD AT/XT keyboard adapter", sizeof(serio->name)); 172 + strscpy(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 } 175 175
+2 -2
drivers/input/serio/pcips2.c
··· 149 149 serio->write = pcips2_write; 150 150 serio->open = pcips2_open; 151 151 serio->close = pcips2_close; 152 - strlcpy(serio->name, pci_name(dev), sizeof(serio->name)); 153 - strlcpy(serio->phys, dev_name(&dev->dev), sizeof(serio->phys)); 152 + strscpy(serio->name, pci_name(dev), sizeof(serio->name)); 153 + strscpy(serio->phys, dev_name(&dev->dev), sizeof(serio->phys)); 154 154 serio->port_data = ps2if; 155 155 serio->dev.parent = &dev->dev; 156 156 ps2if->io = serio;
+2 -2
drivers/input/serio/ps2-gpio.c
··· 449 449 serio->write = drvdata->write_enable ? ps2_gpio_write : NULL; 450 450 serio->port_data = drvdata; 451 451 serio->dev.parent = dev; 452 - strlcpy(serio->name, dev_name(dev), sizeof(serio->name)); 453 - strlcpy(serio->phys, dev_name(dev), sizeof(serio->phys)); 452 + strscpy(serio->name, dev_name(dev), sizeof(serio->name)); 453 + strscpy(serio->phys, dev_name(dev), sizeof(serio->phys)); 454 454 455 455 drvdata->serio = serio; 456 456 drvdata->dev = dev;
+1 -1
drivers/input/serio/ps2mult.c
··· 131 131 if (!serio) 132 132 return -ENOMEM; 133 133 134 - strlcpy(serio->name, "TQC PS/2 Multiplexer", sizeof(serio->name)); 134 + strscpy(serio->name, "TQC PS/2 Multiplexer", sizeof(serio->name)); 135 135 snprintf(serio->phys, sizeof(serio->phys), 136 136 "%s/port%d", mx_serio->phys, i); 137 137 serio->id.type = SERIO_8042;
+2 -5
drivers/input/serio/q40kbd.c
··· 10 10 * Q40 PS/2 keyboard controller driver for Linux/m68k 11 11 */ 12 12 13 - /* 14 - */ 15 - 16 13 #include <linux/module.h> 17 14 #include <linux/serio.h> 18 15 #include <linux/interrupt.h> ··· 123 126 port->close = q40kbd_close; 124 127 port->port_data = q40kbd; 125 128 port->dev.parent = &pdev->dev; 126 - strlcpy(port->name, "Q40 Kbd Port", sizeof(port->name)); 127 - strlcpy(port->phys, "Q40", sizeof(port->phys)); 129 + strscpy(port->name, "Q40 Kbd Port", sizeof(port->name)); 130 + strscpy(port->phys, "Q40", sizeof(port->phys)); 128 131 129 132 q40kbd_stop(); 130 133
+2 -5
drivers/input/serio/rpckbd.c
··· 8 8 * Acorn RiscPC PS/2 keyboard controller driver for Linux/ARM 9 9 */ 10 10 11 - /* 12 - */ 13 - 14 11 #include <linux/module.h> 15 12 #include <linux/interrupt.h> 16 13 #include <linux/serio.h> ··· 125 128 serio->close = rpckbd_close; 126 129 serio->dev.parent = &dev->dev; 127 130 serio->port_data = rpckbd; 128 - strlcpy(serio->name, "RiscPC PS/2 kbd port", sizeof(serio->name)); 129 - strlcpy(serio->phys, "rpckbd/serio0", sizeof(serio->phys)); 131 + strscpy(serio->name, "RiscPC PS/2 kbd port", sizeof(serio->name)); 132 + strscpy(serio->phys, "rpckbd/serio0", sizeof(serio->phys)); 130 133 131 134 platform_set_drvdata(dev, serio); 132 135 serio_register_port(serio);
+2 -2
drivers/input/serio/sa1111ps2.c
··· 267 267 serio->write = ps2_write; 268 268 serio->open = ps2_open; 269 269 serio->close = ps2_close; 270 - strlcpy(serio->name, dev_name(&dev->dev), sizeof(serio->name)); 271 - strlcpy(serio->phys, dev_name(&dev->dev), sizeof(serio->phys)); 270 + strscpy(serio->name, dev_name(&dev->dev), sizeof(serio->name)); 271 + strscpy(serio->phys, dev_name(&dev->dev), sizeof(serio->phys)); 272 272 serio->port_data = ps2if; 273 273 serio->dev.parent = &dev->dev; 274 274 ps2if->io = serio;
-3
drivers/input/serio/serio.c
··· 7 7 * Copyright (c) 2003 Daniele Bellucci 8 8 */ 9 9 10 - /* 11 - */ 12 - 13 10 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 14 11 15 12 #include <linux/stddef.h>
+1 -1
drivers/input/serio/serport.c
··· 171 171 if (!serio) 172 172 return -ENOMEM; 173 173 174 - strlcpy(serio->name, "Serial port", sizeof(serio->name)); 174 + strscpy(serio->name, "Serial port", sizeof(serio->name)); 175 175 snprintf(serio->phys, sizeof(serio->phys), "%s/serio0", tty_name(tty)); 176 176 serio->id = serport->id; 177 177 serio->id.type = SERIO_RS232;
+2 -2
drivers/input/serio/sun4i-ps2.c
··· 256 256 serio->close = sun4i_ps2_close; 257 257 serio->port_data = drvdata; 258 258 serio->dev.parent = dev; 259 - strlcpy(serio->name, dev_name(dev), sizeof(serio->name)); 260 - strlcpy(serio->phys, dev_name(dev), sizeof(serio->phys)); 259 + strscpy(serio->name, dev_name(dev), sizeof(serio->name)); 260 + strscpy(serio->phys, dev_name(dev), sizeof(serio->phys)); 261 261 262 262 /* shutoff interrupt */ 263 263 writel(0, drvdata->reg_base + PS2_REG_GCTL);
+1 -4
drivers/input/tablet/acecad.c
··· 9 9 * v3.2 - Added sysfs support 10 10 */ 11 11 12 - /* 13 - */ 14 - 15 12 #include <linux/kernel.h> 16 13 #include <linux/slab.h> 17 14 #include <linux/module.h> ··· 152 155 acecad->input = input_dev; 153 156 154 157 if (dev->manufacturer) 155 - strlcpy(acecad->name, dev->manufacturer, sizeof(acecad->name)); 158 + strscpy(acecad->name, dev->manufacturer, sizeof(acecad->name)); 156 159 157 160 if (dev->product) { 158 161 if (dev->manufacturer)
+4 -16
drivers/input/tablet/aiptek.c
··· 1617 1617 1618 1618 static DEVICE_ATTR(firmware_code, S_IRUGO, show_firmwareCode, NULL); 1619 1619 1620 - static struct attribute *aiptek_attributes[] = { 1620 + static struct attribute *aiptek_dev_attrs[] = { 1621 1621 &dev_attr_size.attr, 1622 1622 &dev_attr_pointer_mode.attr, 1623 1623 &dev_attr_coordinate_mode.attr, ··· 1641 1641 NULL 1642 1642 }; 1643 1643 1644 - static const struct attribute_group aiptek_attribute_group = { 1645 - .attrs = aiptek_attributes, 1646 - }; 1644 + ATTRIBUTE_GROUPS(aiptek_dev); 1647 1645 1648 1646 /*********************************************************************** 1649 1647 * This routine is called when a tablet has been identified. It basically ··· 1840 1842 */ 1841 1843 usb_set_intfdata(intf, aiptek); 1842 1844 1843 - /* Set up the sysfs files 1844 - */ 1845 - err = sysfs_create_group(&intf->dev.kobj, &aiptek_attribute_group); 1846 - if (err) { 1847 - dev_warn(&intf->dev, "cannot create sysfs group err: %d\n", 1848 - err); 1849 - goto fail3; 1850 - } 1851 - 1852 1845 /* Register the tablet as an Input Device 1853 1846 */ 1854 1847 err = input_register_device(aiptek->inputdev); 1855 1848 if (err) { 1856 1849 dev_warn(&intf->dev, 1857 1850 "input_register_device returned err: %d\n", err); 1858 - goto fail4; 1851 + goto fail3; 1859 1852 } 1860 1853 return 0; 1861 1854 1862 - fail4: sysfs_remove_group(&intf->dev.kobj, &aiptek_attribute_group); 1863 1855 fail3: usb_free_urb(aiptek->urb); 1864 1856 fail2: usb_free_coherent(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data, 1865 1857 aiptek->data_dma); ··· 1874 1886 */ 1875 1887 usb_kill_urb(aiptek->urb); 1876 1888 input_unregister_device(aiptek->inputdev); 1877 - sysfs_remove_group(&intf->dev.kobj, &aiptek_attribute_group); 1878 1889 usb_free_urb(aiptek->urb); 1879 1890 usb_free_coherent(interface_to_usbdev(intf), 1880 1891 AIPTEK_PACKET_LENGTH, ··· 1887 1900 .probe = aiptek_probe, 1888 1901 .disconnect = aiptek_disconnect, 1889 1902 .id_table = aiptek_ids, 1903 + .dev_groups = aiptek_dev_groups, 1890 1904 }; 1891 1905 1892 1906 module_usb_driver(aiptek_driver);
+1 -4
drivers/input/tablet/hanwang.c
··· 5 5 * Copyright (c) 2010 Xing Wei <weixing@hanwang.com.cn> 6 6 */ 7 7 8 - /* 9 - */ 10 - 11 8 #include <linux/types.h> 12 9 #include <linux/kernel.h> 13 10 #include <linux/slab.h> ··· 353 356 usb_make_path(dev, hanwang->phys, sizeof(hanwang->phys)); 354 357 strlcat(hanwang->phys, "/input0", sizeof(hanwang->phys)); 355 358 356 - strlcpy(hanwang->name, hanwang->features->name, sizeof(hanwang->name)); 359 + strscpy(hanwang->name, hanwang->features->name, sizeof(hanwang->name)); 357 360 input_dev->name = hanwang->name; 358 361 input_dev->phys = hanwang->phys; 359 362 usb_to_input_id(dev, &input_dev->id);
+1 -1
drivers/input/tablet/pegasus_notetaker.c
··· 319 319 pegasus->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 320 320 321 321 if (dev->manufacturer) 322 - strlcpy(pegasus->name, dev->manufacturer, 322 + strscpy(pegasus->name, dev->manufacturer, 323 323 sizeof(pegasus->name)); 324 324 325 325 if (dev->product) {
+1 -1
drivers/input/touchscreen/Kconfig
··· 1335 1335 1336 1336 config TOUCHSCREEN_COLIBRI_VF50 1337 1337 tristate "Toradex Colibri on board touchscreen driver" 1338 - depends on IIO && VF610_ADC 1338 + depends on IIO 1339 1339 depends on GPIOLIB || COMPILE_TEST 1340 1340 help 1341 1341 Say Y here if you have a Colibri VF50 and plan to use
+4 -4
drivers/input/touchscreen/atmel_mxt_ts.c
··· 2497 2497 { 2498 2498 struct mxt_data *data = video_drvdata(file); 2499 2499 2500 - strlcpy(cap->driver, "atmel_mxt_ts", sizeof(cap->driver)); 2501 - strlcpy(cap->card, "atmel_mxt_ts touch", sizeof(cap->card)); 2500 + strscpy(cap->driver, "atmel_mxt_ts", sizeof(cap->driver)); 2501 + strscpy(cap->card, "atmel_mxt_ts touch", sizeof(cap->card)); 2502 2502 snprintf(cap->bus_info, sizeof(cap->bus_info), 2503 2503 "I2C:%s", dev_name(&data->client->dev)); 2504 2504 return 0; ··· 2514 2514 2515 2515 switch (i->index) { 2516 2516 case MXT_V4L_INPUT_REFS: 2517 - strlcpy(i->name, "Mutual Capacitance References", 2517 + strscpy(i->name, "Mutual Capacitance References", 2518 2518 sizeof(i->name)); 2519 2519 break; 2520 2520 case MXT_V4L_INPUT_DELTAS: 2521 - strlcpy(i->name, "Mutual Capacitance Deltas", sizeof(i->name)); 2521 + strscpy(i->name, "Mutual Capacitance Deltas", sizeof(i->name)); 2522 2522 break; 2523 2523 } 2524 2524
+61 -94
drivers/input/touchscreen/auo-pixcir-ts.c
··· 10 10 * Copyright (c) 2008 QUALCOMM USA, INC. 11 11 */ 12 12 13 + #include <linux/err.h> 13 14 #include <linux/kernel.h> 14 15 #include <linux/module.h> 15 16 #include <linux/interrupt.h> ··· 20 19 #include <linux/i2c.h> 21 20 #include <linux/mutex.h> 22 21 #include <linux/delay.h> 23 - #include <linux/gpio.h> 24 - #include <linux/input/auo-pixcir-ts.h> 22 + #include <linux/gpio/consumer.h> 25 23 #include <linux/of.h> 26 - #include <linux/of_gpio.h> 24 + #include <linux/property.h> 27 25 28 26 /* 29 27 * Coordinate calculation: ··· 69 69 #define AUO_PIXCIR_INT_RELEASE (1 << 4) 70 70 #define AUO_PIXCIR_INT_ENABLE (1 << 3) 71 71 #define AUO_PIXCIR_INT_POL_HIGH (1 << 2) 72 + 73 + /* 74 + * Interrupt modes: 75 + * periodical: interrupt is asserted periodicaly 76 + * compare coordinates: interrupt is asserted when coordinates change 77 + * indicate touch: interrupt is asserted during touch 78 + */ 79 + #define AUO_PIXCIR_INT_PERIODICAL 0x00 80 + #define AUO_PIXCIR_INT_COMP_COORD 0x01 81 + #define AUO_PIXCIR_INT_TOUCH_IND 0x02 72 82 #define AUO_PIXCIR_INT_MODE_MASK 0x03 73 83 74 84 /* ··· 113 103 struct auo_pixcir_ts { 114 104 struct i2c_client *client; 115 105 struct input_dev *input; 116 - const struct auo_pixcir_ts_platdata *pdata; 106 + struct gpio_desc *gpio_int; 107 + struct gpio_desc *gpio_rst; 117 108 char phys[32]; 118 109 119 - /* special handling for touch_indicate interupt mode */ 110 + unsigned int x_max; 111 + unsigned int y_max; 112 + 113 + /* special handling for touch_indicate interrupt mode */ 120 114 bool touch_ind_mode; 121 115 122 116 wait_queue_head_t wait; ··· 139 125 struct auo_point_t *point) 140 126 { 141 127 struct i2c_client *client = ts->client; 142 - const struct auo_pixcir_ts_platdata *pdata = ts->pdata; 143 128 uint8_t raw_coord[8]; 144 129 uint8_t raw_area[4]; 145 130 int i, ret; ··· 165 152 point[i].coord_y = 166 153 raw_coord[4 * i + 3] << 8 | raw_coord[4 * i + 2]; 167 154 168 - if (point[i].coord_x > pdata->x_max || 169 - point[i].coord_y > pdata->y_max) { 155 + if (point[i].coord_x > ts->x_max || 156 + point[i].coord_y > ts->y_max) { 170 157 dev_warn(&client->dev, "coordinates (%d,%d) invalid\n", 171 158 point[i].coord_x, point[i].coord_y); 172 159 point[i].coord_x = point[i].coord_y = 0; ··· 184 171 static irqreturn_t auo_pixcir_interrupt(int irq, void *dev_id) 185 172 { 186 173 struct auo_pixcir_ts *ts = dev_id; 187 - const struct auo_pixcir_ts_platdata *pdata = ts->pdata; 188 174 struct auo_point_t point[AUO_PIXCIR_REPORT_POINTS]; 189 175 int i; 190 176 int ret; ··· 194 182 195 183 /* check for up event in touch touch_ind_mode */ 196 184 if (ts->touch_ind_mode) { 197 - if (gpio_get_value(pdata->gpio_int) == 0) { 185 + if (gpiod_get_value_cansleep(ts->gpio_int) == 0) { 198 186 input_mt_sync(ts->input); 199 187 input_report_key(ts->input, BTN_TOUCH, 0); 200 188 input_sync(ts->input); ··· 290 278 return 0; 291 279 } 292 280 293 - static int auo_pixcir_int_config(struct auo_pixcir_ts *ts, 294 - int int_setting) 281 + static int auo_pixcir_int_config(struct auo_pixcir_ts *ts, int int_setting) 295 282 { 296 283 struct i2c_client *client = ts->client; 297 - const struct auo_pixcir_ts_platdata *pdata = ts->pdata; 298 284 int ret; 299 285 300 286 ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_INT_SETTING); ··· 314 304 return ret; 315 305 } 316 306 317 - ts->touch_ind_mode = pdata->int_setting == AUO_PIXCIR_INT_TOUCH_IND; 307 + ts->touch_ind_mode = int_setting == AUO_PIXCIR_INT_TOUCH_IND; 318 308 319 309 return 0; 320 310 } ··· 475 465 static SIMPLE_DEV_PM_OPS(auo_pixcir_pm_ops, 476 466 auo_pixcir_suspend, auo_pixcir_resume); 477 467 478 - #ifdef CONFIG_OF 479 - static struct auo_pixcir_ts_platdata *auo_pixcir_parse_dt(struct device *dev) 480 - { 481 - struct auo_pixcir_ts_platdata *pdata; 482 - struct device_node *np = dev->of_node; 483 - 484 - if (!np) 485 - return ERR_PTR(-ENOENT); 486 - 487 - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); 488 - if (!pdata) 489 - return ERR_PTR(-ENOMEM); 490 - 491 - pdata->gpio_int = of_get_gpio(np, 0); 492 - if (!gpio_is_valid(pdata->gpio_int)) { 493 - dev_err(dev, "failed to get interrupt gpio\n"); 494 - return ERR_PTR(-EINVAL); 495 - } 496 - 497 - pdata->gpio_rst = of_get_gpio(np, 1); 498 - if (!gpio_is_valid(pdata->gpio_rst)) { 499 - dev_err(dev, "failed to get reset gpio\n"); 500 - return ERR_PTR(-EINVAL); 501 - } 502 - 503 - if (of_property_read_u32(np, "x-size", &pdata->x_max)) { 504 - dev_err(dev, "failed to get x-size property\n"); 505 - return ERR_PTR(-EINVAL); 506 - } 507 - 508 - if (of_property_read_u32(np, "y-size", &pdata->y_max)) { 509 - dev_err(dev, "failed to get y-size property\n"); 510 - return ERR_PTR(-EINVAL); 511 - } 512 - 513 - /* default to asserting the interrupt when the screen is touched */ 514 - pdata->int_setting = AUO_PIXCIR_INT_TOUCH_IND; 515 - 516 - return pdata; 517 - } 518 - #else 519 - static struct auo_pixcir_ts_platdata *auo_pixcir_parse_dt(struct device *dev) 520 - { 521 - return ERR_PTR(-EINVAL); 522 - } 523 - #endif 524 - 525 468 static void auo_pixcir_reset(void *data) 526 469 { 527 470 struct auo_pixcir_ts *ts = data; 528 471 529 - gpio_set_value(ts->pdata->gpio_rst, 0); 472 + gpiod_set_value_cansleep(ts->gpio_rst, 1); 530 473 } 531 474 532 475 static int auo_pixcir_probe(struct i2c_client *client, 533 476 const struct i2c_device_id *id) 534 477 { 535 - const struct auo_pixcir_ts_platdata *pdata; 536 478 struct auo_pixcir_ts *ts; 537 479 struct input_dev *input_dev; 538 480 int version; 539 481 int error; 540 482 541 - pdata = dev_get_platdata(&client->dev); 542 - if (!pdata) { 543 - pdata = auo_pixcir_parse_dt(&client->dev); 544 - if (IS_ERR(pdata)) 545 - return PTR_ERR(pdata); 546 - } 547 - 548 - ts = devm_kzalloc(&client->dev, 549 - sizeof(struct auo_pixcir_ts), GFP_KERNEL); 483 + ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); 550 484 if (!ts) 551 485 return -ENOMEM; 552 486 ··· 500 546 return -ENOMEM; 501 547 } 502 548 503 - ts->pdata = pdata; 504 549 ts->client = client; 505 550 ts->input = input_dev; 506 551 ts->touch_ind_mode = 0; ··· 508 555 509 556 snprintf(ts->phys, sizeof(ts->phys), 510 557 "%s/input0", dev_name(&client->dev)); 558 + 559 + if (device_property_read_u32(&client->dev, "x-size", &ts->x_max)) { 560 + dev_err(&client->dev, "failed to get x-size property\n"); 561 + return -EINVAL; 562 + } 563 + 564 + if (device_property_read_u32(&client->dev, "y-size", &ts->y_max)) { 565 + dev_err(&client->dev, "failed to get y-size property\n"); 566 + return -EINVAL; 567 + } 511 568 512 569 input_dev->name = "AUO-Pixcir touchscreen"; 513 570 input_dev->phys = ts->phys; ··· 532 569 __set_bit(BTN_TOUCH, input_dev->keybit); 533 570 534 571 /* For single touch */ 535 - input_set_abs_params(input_dev, ABS_X, 0, pdata->x_max, 0, 0); 536 - input_set_abs_params(input_dev, ABS_Y, 0, pdata->y_max, 0, 0); 572 + input_set_abs_params(input_dev, ABS_X, 0, ts->x_max, 0, 0); 573 + input_set_abs_params(input_dev, ABS_Y, 0, ts->y_max, 0, 0); 537 574 538 575 /* For multi touch */ 539 - input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, 540 - pdata->x_max, 0, 0); 541 - input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, 542 - pdata->y_max, 0, 0); 543 - input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 544 - AUO_PIXCIR_MAX_AREA, 0, 0); 545 - input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, 546 - AUO_PIXCIR_MAX_AREA, 0, 0); 576 + input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, ts->x_max, 0, 0); 577 + input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, ts->y_max, 0, 0); 578 + input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 579 + 0, AUO_PIXCIR_MAX_AREA, 0, 0); 580 + input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 581 + 0, AUO_PIXCIR_MAX_AREA, 0, 0); 547 582 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0); 548 583 549 584 input_set_drvdata(ts->input, ts); 550 585 551 - error = devm_gpio_request_one(&client->dev, pdata->gpio_int, 552 - GPIOF_DIR_IN, "auo_pixcir_ts_int"); 586 + ts->gpio_int = devm_gpiod_get_index(&client->dev, NULL, 0, GPIOD_IN); 587 + error = PTR_ERR_OR_ZERO(ts->gpio_int); 553 588 if (error) { 554 - dev_err(&client->dev, "request of gpio %d failed, %d\n", 555 - pdata->gpio_int, error); 589 + dev_err(&client->dev, 590 + "request of int gpio failed: %d\n", error); 556 591 return error; 557 592 } 558 593 559 - error = devm_gpio_request_one(&client->dev, pdata->gpio_rst, 560 - GPIOF_DIR_OUT | GPIOF_INIT_HIGH, 561 - "auo_pixcir_ts_rst"); 594 + gpiod_set_consumer_name(ts->gpio_int, "auo_pixcir_ts_int"); 595 + 596 + /* Take the chip out of reset */ 597 + ts->gpio_rst = devm_gpiod_get_index(&client->dev, NULL, 1, 598 + GPIOD_OUT_LOW); 599 + error = PTR_ERR_OR_ZERO(ts->gpio_rst); 562 600 if (error) { 563 - dev_err(&client->dev, "request of gpio %d failed, %d\n", 564 - pdata->gpio_rst, error); 601 + dev_err(&client->dev, 602 + "request of reset gpio failed: %d\n", error); 565 603 return error; 566 604 } 605 + 606 + gpiod_set_consumer_name(ts->gpio_rst, "auo_pixcir_ts_rst"); 567 607 568 608 error = devm_add_action_or_reset(&client->dev, auo_pixcir_reset, ts); 569 609 if (error) { ··· 585 619 586 620 dev_info(&client->dev, "firmware version 0x%X\n", version); 587 621 588 - error = auo_pixcir_int_config(ts, pdata->int_setting); 622 + /* default to asserting the interrupt when the screen is touched */ 623 + error = auo_pixcir_int_config(ts, AUO_PIXCIR_INT_TOUCH_IND); 589 624 if (error) 590 625 return error; 591 626 592 627 error = devm_request_threaded_irq(&client->dev, client->irq, 593 628 NULL, auo_pixcir_interrupt, 594 - IRQF_TRIGGER_RISING | IRQF_ONESHOT, 629 + IRQF_ONESHOT, 595 630 input_dev->name, ts); 596 631 if (error) { 597 632 dev_err(&client->dev, "irq %d requested failed, %d\n",
+9 -21
drivers/input/touchscreen/chipone_icn8505.c
··· 364 364 365 365 static int icn8505_probe_acpi(struct icn8505_data *icn8505, struct device *dev) 366 366 { 367 - struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 368 - const char *subsys = "unknown"; 369 - struct acpi_device *adev; 370 - union acpi_object *obj; 371 - acpi_status status; 367 + const char *subsys; 368 + int error; 372 369 373 - adev = ACPI_COMPANION(dev); 374 - if (!adev) 375 - return -ENODEV; 376 - 377 - status = acpi_evaluate_object(adev->handle, "_SUB", NULL, &buffer); 378 - if (ACPI_SUCCESS(status)) { 379 - obj = buffer.pointer; 380 - if (obj->type == ACPI_TYPE_STRING) 381 - subsys = obj->string.pointer; 382 - else 383 - dev_warn(dev, "Warning ACPI _SUB did not return a string\n"); 384 - } else { 385 - dev_warn(dev, "Warning ACPI _SUB failed: %#x\n", status); 386 - buffer.pointer = NULL; 387 - } 370 + subsys = acpi_get_subsystem_id(ACPI_HANDLE(dev)); 371 + error = PTR_ERR_OR_ZERO(subsys); 372 + if (error == -ENODATA) 373 + subsys = "unknown"; 374 + else if (error) 375 + return error; 388 376 389 377 snprintf(icn8505->firmware_name, sizeof(icn8505->firmware_name), 390 378 "chipone/icn8505-%s.fw", subsys); 391 379 392 - kfree(buffer.pointer); 380 + kfree_const(subsys); 393 381 return 0; 394 382 } 395 383
+6 -6
drivers/input/touchscreen/edt-ft5x06.c
··· 912 912 p = strchr(rdbuf, '*'); 913 913 if (p) 914 914 *p++ = '\0'; 915 - strlcpy(model_name, rdbuf + 1, EDT_NAME_LEN); 916 - strlcpy(fw_version, p ? p : "", EDT_NAME_LEN); 915 + strscpy(model_name, rdbuf + 1, EDT_NAME_LEN); 916 + strscpy(fw_version, p ? p : "", EDT_NAME_LEN); 917 917 } else if (!strncasecmp(rdbuf, "EP0", 3)) { 918 918 tsdata->version = EDT_M12; 919 919 ··· 926 926 p = strchr(rdbuf, '*'); 927 927 if (p) 928 928 *p++ = '\0'; 929 - strlcpy(model_name, rdbuf, EDT_NAME_LEN); 930 - strlcpy(fw_version, p ? p : "", EDT_NAME_LEN); 929 + strscpy(model_name, rdbuf, EDT_NAME_LEN); 930 + strscpy(fw_version, p ? p : "", EDT_NAME_LEN); 931 931 } else { 932 932 /* If it is not an EDT M06/M12 touchscreen, then the model 933 933 * detection is a bit hairy. The different ft5x06 ··· 945 945 if (error) 946 946 return error; 947 947 948 - strlcpy(fw_version, rdbuf, 2); 948 + strscpy(fw_version, rdbuf, 2); 949 949 950 950 error = edt_ft5x06_ts_readwrite(client, 1, "\xA8", 951 951 1, rdbuf); ··· 981 981 1, rdbuf); 982 982 if (error) 983 983 return error; 984 - strlcpy(fw_version, rdbuf, 1); 984 + strscpy(fw_version, rdbuf, 1); 985 985 snprintf(model_name, EDT_NAME_LEN, 986 986 "EVERVISION-FT5726NEi"); 987 987 break;
-3
drivers/input/touchscreen/gunze.c
··· 7 7 * Gunze AHL-51S touchscreen driver for Linux 8 8 */ 9 9 10 - /* 11 - */ 12 - 13 10 #include <linux/errno.h> 14 11 #include <linux/kernel.h> 15 12 #include <linux/module.h>
+3 -3
drivers/input/touchscreen/sur40.c
··· 939 939 { 940 940 struct sur40_state *sur40 = video_drvdata(file); 941 941 942 - strlcpy(cap->driver, DRIVER_SHORT, sizeof(cap->driver)); 943 - strlcpy(cap->card, DRIVER_LONG, sizeof(cap->card)); 942 + strscpy(cap->driver, DRIVER_SHORT, sizeof(cap->driver)); 943 + strscpy(cap->card, DRIVER_LONG, sizeof(cap->card)); 944 944 usb_make_path(sur40->usbdev, cap->bus_info, sizeof(cap->bus_info)); 945 945 return 0; 946 946 } ··· 952 952 return -EINVAL; 953 953 i->type = V4L2_INPUT_TYPE_TOUCH; 954 954 i->std = V4L2_STD_UNKNOWN; 955 - strlcpy(i->name, "In-Cell Sensor", sizeof(i->name)); 955 + strscpy(i->name, "In-Cell Sensor", sizeof(i->name)); 956 956 i->capabilities = 0; 957 957 return 0; 958 958 }
+1 -1
drivers/input/touchscreen/usbtouchscreen.c
··· 1708 1708 usbtouch->input = input_dev; 1709 1709 1710 1710 if (udev->manufacturer) 1711 - strlcpy(usbtouch->name, udev->manufacturer, sizeof(usbtouch->name)); 1711 + strscpy(usbtouch->name, udev->manufacturer, sizeof(usbtouch->name)); 1712 1712 1713 1713 if (udev->product) { 1714 1714 if (udev->manufacturer)
+3 -3
drivers/input/touchscreen/wacom_w8001.c
··· 625 625 /* For backwards-compatibility we compose the basename based on 626 626 * capabilities and then just append the tool type 627 627 */ 628 - strlcpy(basename, "Wacom Serial", sizeof(basename)); 628 + strscpy(basename, "Wacom Serial", sizeof(basename)); 629 629 630 630 err_pen = w8001_setup_pen(w8001, basename, sizeof(basename)); 631 631 err_touch = w8001_setup_touch(w8001, basename, sizeof(basename)); ··· 635 635 } 636 636 637 637 if (!err_pen) { 638 - strlcpy(w8001->pen_name, basename, sizeof(w8001->pen_name)); 638 + strscpy(w8001->pen_name, basename, sizeof(w8001->pen_name)); 639 639 strlcat(w8001->pen_name, " Pen", sizeof(w8001->pen_name)); 640 640 input_dev_pen->name = w8001->pen_name; 641 641 ··· 651 651 } 652 652 653 653 if (!err_touch) { 654 - strlcpy(w8001->touch_name, basename, sizeof(w8001->touch_name)); 654 + strscpy(w8001->touch_name, basename, sizeof(w8001->touch_name)); 655 655 strlcat(w8001->touch_name, " Finger", 656 656 sizeof(w8001->touch_name)); 657 657 input_dev_touch->name = w8001->touch_name;
+2 -2
include/linux/bma150.h
··· 33 33 unsigned char lg_hyst; /* Low-G hysterisis */ 34 34 unsigned char lg_dur; /* Low-G duration */ 35 35 unsigned char lg_thres; /* Low-G threshold */ 36 - unsigned char range; /* one of BMA0150_RANGE_xxx */ 37 - unsigned char bandwidth; /* one of BMA0150_BW_xxx */ 36 + unsigned char range; /* one of BMA150_RANGE_xxx */ 37 + unsigned char bandwidth; /* one of BMA150_BW_xxx */ 38 38 }; 39 39 40 40 struct bma150_platform_data {
+1 -1
include/linux/gameport.h
··· 110 110 111 111 static inline void gameport_set_name(struct gameport *gameport, const char *name) 112 112 { 113 - strlcpy(gameport->name, name, sizeof(gameport->name)); 113 + strscpy(gameport->name, name, sizeof(gameport->name)); 114 114 } 115 115 116 116 /*
-44
include/linux/input/auo-pixcir-ts.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-only */ 2 - /* 3 - * Driver for AUO in-cell touchscreens 4 - * 5 - * Copyright (c) 2011 Heiko Stuebner <heiko@sntech.de> 6 - * 7 - * based on auo_touch.h from Dell Streak kernel 8 - * 9 - * Copyright (c) 2008 QUALCOMM Incorporated. 10 - * Copyright (c) 2008 QUALCOMM USA, INC. 11 - */ 12 - 13 - #ifndef __AUO_PIXCIR_TS_H__ 14 - #define __AUO_PIXCIR_TS_H__ 15 - 16 - /* 17 - * Interrupt modes: 18 - * periodical: interrupt is asserted periodicaly 19 - * compare coordinates: interrupt is asserted when coordinates change 20 - * indicate touch: interrupt is asserted during touch 21 - */ 22 - #define AUO_PIXCIR_INT_PERIODICAL 0x00 23 - #define AUO_PIXCIR_INT_COMP_COORD 0x01 24 - #define AUO_PIXCIR_INT_TOUCH_IND 0x02 25 - 26 - /* 27 - * @gpio_int interrupt gpio 28 - * @int_setting one of AUO_PIXCIR_INT_* 29 - * @init_hw hardwarespecific init 30 - * @exit_hw hardwarespecific shutdown 31 - * @x_max x-resolution 32 - * @y_max y-resolution 33 - */ 34 - struct auo_pixcir_ts_platdata { 35 - int gpio_int; 36 - int gpio_rst; 37 - 38 - int int_setting; 39 - 40 - unsigned int x_max; 41 - unsigned int y_max; 42 - }; 43 - 44 - #endif
-171
include/linux/platform_data/adp5588.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 - /* 3 - * Analog Devices ADP5588 I/O Expander and QWERTY Keypad Controller 4 - * 5 - * Copyright 2009-2010 Analog Devices Inc. 6 - */ 7 - 8 - #ifndef _ADP5588_H 9 - #define _ADP5588_H 10 - 11 - #define DEV_ID 0x00 /* Device ID */ 12 - #define CFG 0x01 /* Configuration Register1 */ 13 - #define INT_STAT 0x02 /* Interrupt Status Register */ 14 - #define KEY_LCK_EC_STAT 0x03 /* Key Lock and Event Counter Register */ 15 - #define Key_EVENTA 0x04 /* Key Event Register A */ 16 - #define Key_EVENTB 0x05 /* Key Event Register B */ 17 - #define Key_EVENTC 0x06 /* Key Event Register C */ 18 - #define Key_EVENTD 0x07 /* Key Event Register D */ 19 - #define Key_EVENTE 0x08 /* Key Event Register E */ 20 - #define Key_EVENTF 0x09 /* Key Event Register F */ 21 - #define Key_EVENTG 0x0A /* Key Event Register G */ 22 - #define Key_EVENTH 0x0B /* Key Event Register H */ 23 - #define Key_EVENTI 0x0C /* Key Event Register I */ 24 - #define Key_EVENTJ 0x0D /* Key Event Register J */ 25 - #define KP_LCK_TMR 0x0E /* Keypad Lock1 to Lock2 Timer */ 26 - #define UNLOCK1 0x0F /* Unlock Key1 */ 27 - #define UNLOCK2 0x10 /* Unlock Key2 */ 28 - #define GPIO_INT_STAT1 0x11 /* GPIO Interrupt Status */ 29 - #define GPIO_INT_STAT2 0x12 /* GPIO Interrupt Status */ 30 - #define GPIO_INT_STAT3 0x13 /* GPIO Interrupt Status */ 31 - #define GPIO_DAT_STAT1 0x14 /* GPIO Data Status, Read twice to clear */ 32 - #define GPIO_DAT_STAT2 0x15 /* GPIO Data Status, Read twice to clear */ 33 - #define GPIO_DAT_STAT3 0x16 /* GPIO Data Status, Read twice to clear */ 34 - #define GPIO_DAT_OUT1 0x17 /* GPIO DATA OUT */ 35 - #define GPIO_DAT_OUT2 0x18 /* GPIO DATA OUT */ 36 - #define GPIO_DAT_OUT3 0x19 /* GPIO DATA OUT */ 37 - #define GPIO_INT_EN1 0x1A /* GPIO Interrupt Enable */ 38 - #define GPIO_INT_EN2 0x1B /* GPIO Interrupt Enable */ 39 - #define GPIO_INT_EN3 0x1C /* GPIO Interrupt Enable */ 40 - #define KP_GPIO1 0x1D /* Keypad or GPIO Selection */ 41 - #define KP_GPIO2 0x1E /* Keypad or GPIO Selection */ 42 - #define KP_GPIO3 0x1F /* Keypad or GPIO Selection */ 43 - #define GPI_EM1 0x20 /* GPI Event Mode 1 */ 44 - #define GPI_EM2 0x21 /* GPI Event Mode 2 */ 45 - #define GPI_EM3 0x22 /* GPI Event Mode 3 */ 46 - #define GPIO_DIR1 0x23 /* GPIO Data Direction */ 47 - #define GPIO_DIR2 0x24 /* GPIO Data Direction */ 48 - #define GPIO_DIR3 0x25 /* GPIO Data Direction */ 49 - #define GPIO_INT_LVL1 0x26 /* GPIO Edge/Level Detect */ 50 - #define GPIO_INT_LVL2 0x27 /* GPIO Edge/Level Detect */ 51 - #define GPIO_INT_LVL3 0x28 /* GPIO Edge/Level Detect */ 52 - #define Debounce_DIS1 0x29 /* Debounce Disable */ 53 - #define Debounce_DIS2 0x2A /* Debounce Disable */ 54 - #define Debounce_DIS3 0x2B /* Debounce Disable */ 55 - #define GPIO_PULL1 0x2C /* GPIO Pull Disable */ 56 - #define GPIO_PULL2 0x2D /* GPIO Pull Disable */ 57 - #define GPIO_PULL3 0x2E /* GPIO Pull Disable */ 58 - #define CMP_CFG_STAT 0x30 /* Comparator Configuration and Status Register */ 59 - #define CMP_CONFG_SENS1 0x31 /* Sensor1 Comparator Configuration Register */ 60 - #define CMP_CONFG_SENS2 0x32 /* L2 Light Sensor Reference Level, Output Falling for Sensor 1 */ 61 - #define CMP1_LVL2_TRIP 0x33 /* L2 Light Sensor Hysteresis (Active when Output Rising) for Sensor 1 */ 62 - #define CMP1_LVL2_HYS 0x34 /* L3 Light Sensor Reference Level, Output Falling For Sensor 1 */ 63 - #define CMP1_LVL3_TRIP 0x35 /* L3 Light Sensor Hysteresis (Active when Output Rising) For Sensor 1 */ 64 - #define CMP1_LVL3_HYS 0x36 /* Sensor 2 Comparator Configuration Register */ 65 - #define CMP2_LVL2_TRIP 0x37 /* L2 Light Sensor Reference Level, Output Falling for Sensor 2 */ 66 - #define CMP2_LVL2_HYS 0x38 /* L2 Light Sensor Hysteresis (Active when Output Rising) for Sensor 2 */ 67 - #define CMP2_LVL3_TRIP 0x39 /* L3 Light Sensor Reference Level, Output Falling For Sensor 2 */ 68 - #define CMP2_LVL3_HYS 0x3A /* L3 Light Sensor Hysteresis (Active when Output Rising) For Sensor 2 */ 69 - #define CMP1_ADC_DAT_R1 0x3B /* Comparator 1 ADC data Register1 */ 70 - #define CMP1_ADC_DAT_R2 0x3C /* Comparator 1 ADC data Register2 */ 71 - #define CMP2_ADC_DAT_R1 0x3D /* Comparator 2 ADC data Register1 */ 72 - #define CMP2_ADC_DAT_R2 0x3E /* Comparator 2 ADC data Register2 */ 73 - 74 - #define ADP5588_DEVICE_ID_MASK 0xF 75 - 76 - /* Configuration Register1 */ 77 - #define ADP5588_AUTO_INC (1 << 7) 78 - #define ADP5588_GPIEM_CFG (1 << 6) 79 - #define ADP5588_OVR_FLOW_M (1 << 5) 80 - #define ADP5588_INT_CFG (1 << 4) 81 - #define ADP5588_OVR_FLOW_IEN (1 << 3) 82 - #define ADP5588_K_LCK_IM (1 << 2) 83 - #define ADP5588_GPI_IEN (1 << 1) 84 - #define ADP5588_KE_IEN (1 << 0) 85 - 86 - /* Interrupt Status Register */ 87 - #define ADP5588_CMP2_INT (1 << 5) 88 - #define ADP5588_CMP1_INT (1 << 4) 89 - #define ADP5588_OVR_FLOW_INT (1 << 3) 90 - #define ADP5588_K_LCK_INT (1 << 2) 91 - #define ADP5588_GPI_INT (1 << 1) 92 - #define ADP5588_KE_INT (1 << 0) 93 - 94 - /* Key Lock and Event Counter Register */ 95 - #define ADP5588_K_LCK_EN (1 << 6) 96 - #define ADP5588_LCK21 0x30 97 - #define ADP5588_KEC 0xF 98 - 99 - #define ADP5588_MAXGPIO 18 100 - #define ADP5588_BANK(offs) ((offs) >> 3) 101 - #define ADP5588_BIT(offs) (1u << ((offs) & 0x7)) 102 - 103 - /* Put one of these structures in i2c_board_info platform_data */ 104 - 105 - #define ADP5588_KEYMAPSIZE 80 106 - 107 - #define GPI_PIN_ROW0 97 108 - #define GPI_PIN_ROW1 98 109 - #define GPI_PIN_ROW2 99 110 - #define GPI_PIN_ROW3 100 111 - #define GPI_PIN_ROW4 101 112 - #define GPI_PIN_ROW5 102 113 - #define GPI_PIN_ROW6 103 114 - #define GPI_PIN_ROW7 104 115 - #define GPI_PIN_COL0 105 116 - #define GPI_PIN_COL1 106 117 - #define GPI_PIN_COL2 107 118 - #define GPI_PIN_COL3 108 119 - #define GPI_PIN_COL4 109 120 - #define GPI_PIN_COL5 110 121 - #define GPI_PIN_COL6 111 122 - #define GPI_PIN_COL7 112 123 - #define GPI_PIN_COL8 113 124 - #define GPI_PIN_COL9 114 125 - 126 - #define GPI_PIN_ROW_BASE GPI_PIN_ROW0 127 - #define GPI_PIN_ROW_END GPI_PIN_ROW7 128 - #define GPI_PIN_COL_BASE GPI_PIN_COL0 129 - #define GPI_PIN_COL_END GPI_PIN_COL9 130 - 131 - #define GPI_PIN_BASE GPI_PIN_ROW_BASE 132 - #define GPI_PIN_END GPI_PIN_COL_END 133 - 134 - #define ADP5588_GPIMAPSIZE_MAX (GPI_PIN_END - GPI_PIN_BASE + 1) 135 - 136 - struct adp5588_gpi_map { 137 - unsigned short pin; 138 - unsigned short sw_evt; 139 - }; 140 - 141 - struct adp5588_kpad_platform_data { 142 - int rows; /* Number of rows */ 143 - int cols; /* Number of columns */ 144 - const unsigned short *keymap; /* Pointer to keymap */ 145 - unsigned short keymapsize; /* Keymap size */ 146 - unsigned repeat:1; /* Enable key repeat */ 147 - unsigned en_keylock:1; /* Enable Key Lock feature */ 148 - unsigned short unlock_key1; /* Unlock Key 1 */ 149 - unsigned short unlock_key2; /* Unlock Key 2 */ 150 - const struct adp5588_gpi_map *gpimap; 151 - unsigned short gpimapsize; 152 - const struct adp5588_gpio_platform_data *gpio_data; 153 - }; 154 - 155 - struct i2c_client; /* forward declaration */ 156 - 157 - struct adp5588_gpio_platform_data { 158 - int gpio_start; /* GPIO Chip base # */ 159 - const char *const *names; 160 - unsigned irq_base; /* interrupt base # */ 161 - unsigned pullup_dis_mask; /* Pull-Up Disable Mask */ 162 - int (*setup)(struct i2c_client *client, 163 - unsigned gpio, unsigned ngpio, 164 - void *context); 165 - int (*teardown)(struct i2c_client *client, 166 - unsigned gpio, unsigned ngpio, 167 - void *context); 168 - void *context; 169 - }; 170 - 171 - #endif
+1
include/uapi/linux/input-event-codes.h
··· 862 862 #define ABS_TOOL_WIDTH 0x1c 863 863 864 864 #define ABS_VOLUME 0x20 865 + #define ABS_PROFILE 0x21 865 866 866 867 #define ABS_MISC 0x28 867 868