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

Pull input updates from Dmitry Torokhov:

- a brand new driver for touchpads and touchbars in newer Apple devices

- support for Berlin-A series in goodix-berlin touchscreen driver

- improvements to matrix_keypad driver to better handle GPIOs toggling

- assorted small cleanups in other input drivers

* tag 'input-for-v6.15-rc0' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
Input: goodix_berlin - add support for Berlin-A series
dt-bindings: input: goodix,gt9916: Document gt9897 compatible
dt-bindings: input: matrix_keypad - add wakeup-source property
dt-bindings: input: matrix_keypad - add missing property
Input: pm8941-pwrkey - fix dev_dbg() output in pm8941_pwrkey_irq()
Input: synaptics - hide unused smbus_pnp_ids[] array
Input: apple_z2 - fix potential confusion in Kconfig
Input: matrix_keypad - use fsleep for delays after activating columns
Input: matrix_keypad - add settle time after enabling all columns
dt-bindings: input: matrix_keypad: add settle time after enabling all columns
dt-bindings: input: matrix_keypad: convert to YAML
dt-bindings: input: Correct indentation and style in DTS example
MAINTAINERS: Add entries for Apple Z2 touchscreen driver
Input: apple_z2 - add a driver for Apple Z2 touchscreens
dt-bindings: input: touchscreen: Add Z2 controller
Input: Switch to use hrtimer_setup()
Input: drop vb2_ops_wait_prepare/finish

+813 -149
-49
Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt
··· 1 - * GPIO driven matrix keypad device tree bindings 2 - 3 - GPIO driven matrix keypad is used to interface a SoC with a matrix keypad. 4 - The matrix keypad supports multiple row and column lines, a key can be 5 - placed at each intersection of a unique row and a unique column. The matrix 6 - keypad can sense a key-press and key-release by means of GPIO lines and 7 - report the event using GPIO interrupts to the cpu. 8 - 9 - Required Properties: 10 - - compatible: Should be "gpio-matrix-keypad" 11 - - row-gpios: List of gpios used as row lines. The gpio specifier 12 - for this property depends on the gpio controller to 13 - which these row lines are connected. 14 - - col-gpios: List of gpios used as column lines. The gpio specifier 15 - for this property depends on the gpio controller to 16 - which these column lines are connected. 17 - - linux,keymap: The definition can be found at 18 - bindings/input/matrix-keymap.txt 19 - 20 - Optional Properties: 21 - - linux,no-autorepeat: do no enable autorepeat feature. 22 - - wakeup-source: use any event on keypad as wakeup event. 23 - (Legacy property supported: "linux,wakeup") 24 - - debounce-delay-ms: debounce interval in milliseconds 25 - - col-scan-delay-us: delay, measured in microseconds, that is needed 26 - before we can scan keypad after activating column gpio 27 - - drive-inactive-cols: drive inactive columns during scan, 28 - default is to turn inactive columns into inputs. 29 - 30 - Example: 31 - matrix-keypad { 32 - compatible = "gpio-matrix-keypad"; 33 - debounce-delay-ms = <5>; 34 - col-scan-delay-us = <2>; 35 - 36 - row-gpios = <&gpio2 25 0 37 - &gpio2 26 0 38 - &gpio2 27 0>; 39 - 40 - col-gpios = <&gpio2 21 0 41 - &gpio2 22 0>; 42 - 43 - linux,keymap = <0x0000008B 44 - 0x0100009E 45 - 0x02000069 46 - 0x0001006A 47 - 0x0101001C 48 - 0x0201006C>; 49 - };
+103
Documentation/devicetree/bindings/input/gpio-matrix-keypad.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + 5 + $id: http://devicetree.org/schemas/input/gpio-matrix-keypad.yaml# 6 + $schema: http://devicetree.org/meta-schemas/core.yaml# 7 + 8 + title: GPIO matrix keypad 9 + 10 + maintainers: 11 + - Marek Vasut <marek.vasut@gmail.com> 12 + 13 + description: 14 + GPIO driven matrix keypad is used to interface a SoC with a matrix keypad. 15 + The matrix keypad supports multiple row and column lines, a key can be 16 + placed at each intersection of a unique row and a unique column. The matrix 17 + keypad can sense a key-press and key-release by means of GPIO lines and 18 + report the event using GPIO interrupts to the cpu. 19 + 20 + allOf: 21 + - $ref: /schemas/input/matrix-keymap.yaml# 22 + 23 + properties: 24 + compatible: 25 + const: gpio-matrix-keypad 26 + 27 + row-gpios: 28 + description: 29 + List of GPIOs used as row lines. The gpio specifier for this property 30 + depends on the gpio controller to which these row lines are connected. 31 + 32 + col-gpios: 33 + description: 34 + List of GPIOs used as column lines. The gpio specifier for this property 35 + depends on the gpio controller to which these column lines are connected. 36 + 37 + linux,keymap: true 38 + 39 + linux,no-autorepeat: 40 + type: boolean 41 + description: Do not enable autorepeat feature. 42 + 43 + gpio-activelow: 44 + type: boolean 45 + description: 46 + Force GPIO polarity to active low. 47 + In the absence of this property GPIOs are treated as active high. 48 + 49 + debounce-delay-ms: 50 + description: Debounce interval in milliseconds. 51 + default: 0 52 + 53 + col-scan-delay-us: 54 + description: 55 + Delay, measured in microseconds, that is needed 56 + before we can scan keypad after activating column gpio. 57 + default: 0 58 + 59 + all-cols-on-delay-us: 60 + description: 61 + Delay, measured in microseconds, that is needed 62 + after activating all column gpios. 63 + default: 0 64 + 65 + drive-inactive-cols: 66 + type: boolean 67 + description: 68 + Drive inactive columns during scan, 69 + default is to turn inactive columns into inputs. 70 + 71 + wakeup-source: true 72 + 73 + required: 74 + - compatible 75 + - row-gpios 76 + - col-gpios 77 + - linux,keymap 78 + 79 + additionalProperties: false 80 + 81 + examples: 82 + - | 83 + matrix-keypad { 84 + compatible = "gpio-matrix-keypad"; 85 + debounce-delay-ms = <5>; 86 + col-scan-delay-us = <2>; 87 + 88 + row-gpios = <&gpio2 25 0 89 + &gpio2 26 0 90 + &gpio2 27 0>; 91 + 92 + col-gpios = <&gpio2 21 0 93 + &gpio2 22 0>; 94 + 95 + linux,keymap = <0x0000008B 96 + 0x0100009E 97 + 0x02000069 98 + 0x0001006A 99 + 0x0101001C 100 + 0x0201006C>; 101 + 102 + wakeup-source; 103 + };
+23 -23
Documentation/devicetree/bindings/input/qcom,pm8921-keypad.yaml
··· 62 62 63 63 examples: 64 64 - | 65 - #include <dt-bindings/input/input.h> 66 - #include <dt-bindings/interrupt-controller/irq.h> 67 - pmic { 68 - #address-cells = <1>; 69 - #size-cells = <0>; 65 + #include <dt-bindings/input/input.h> 66 + #include <dt-bindings/interrupt-controller/irq.h> 67 + pmic { 68 + #address-cells = <1>; 69 + #size-cells = <0>; 70 70 71 - keypad@148 { 72 - compatible = "qcom,pm8921-keypad"; 73 - reg = <0x148>; 74 - interrupt-parent = <&pmicintc>; 75 - interrupts = <74 IRQ_TYPE_EDGE_RISING>, <75 IRQ_TYPE_EDGE_RISING>; 76 - linux,keymap = < 77 - MATRIX_KEY(0, 0, KEY_VOLUMEUP) 78 - MATRIX_KEY(0, 1, KEY_VOLUMEDOWN) 79 - MATRIX_KEY(0, 2, KEY_CAMERA_FOCUS) 80 - MATRIX_KEY(0, 3, KEY_CAMERA) 81 - >; 82 - keypad,num-rows = <1>; 83 - keypad,num-columns = <5>; 84 - debounce = <15>; 85 - scan-delay = <32>; 86 - row-hold = <91500>; 87 - }; 88 - }; 71 + keypad@148 { 72 + compatible = "qcom,pm8921-keypad"; 73 + reg = <0x148>; 74 + interrupt-parent = <&pmicintc>; 75 + interrupts = <74 IRQ_TYPE_EDGE_RISING>, <75 IRQ_TYPE_EDGE_RISING>; 76 + linux,keymap = < 77 + MATRIX_KEY(0, 0, KEY_VOLUMEUP) 78 + MATRIX_KEY(0, 1, KEY_VOLUMEDOWN) 79 + MATRIX_KEY(0, 2, KEY_CAMERA_FOCUS) 80 + MATRIX_KEY(0, 3, KEY_CAMERA) 81 + >; 82 + keypad,num-rows = <1>; 83 + keypad,num-columns = <5>; 84 + debounce = <15>; 85 + scan-delay = <32>; 86 + row-hold = <91500>; 87 + }; 88 + }; 89 89 ...
+18 -18
Documentation/devicetree/bindings/input/qcom,pm8921-pwrkey.yaml
··· 52 52 53 53 examples: 54 54 - | 55 - #include <dt-bindings/interrupt-controller/irq.h> 56 - ssbi { 57 - #address-cells = <1>; 58 - #size-cells = <0>; 55 + #include <dt-bindings/interrupt-controller/irq.h> 56 + ssbi { 57 + #address-cells = <1>; 58 + #size-cells = <0>; 59 59 60 - pmic@0 { 61 - reg = <0x0>; 62 - #address-cells = <1>; 63 - #size-cells = <0>; 60 + pmic@0 { 61 + reg = <0x0>; 62 + #address-cells = <1>; 63 + #size-cells = <0>; 64 64 65 - pwrkey@1c { 66 - compatible = "qcom,pm8921-pwrkey"; 67 - reg = <0x1c>; 68 - interrupt-parent = <&pmicint>; 69 - interrupts = <50 IRQ_TYPE_EDGE_RISING>, <51 IRQ_TYPE_EDGE_RISING>; 70 - debounce = <15625>; 71 - pull-up; 72 - }; 73 - }; 74 - }; 65 + pwrkey@1c { 66 + compatible = "qcom,pm8921-pwrkey"; 67 + reg = <0x1c>; 68 + interrupt-parent = <&pmicint>; 69 + interrupts = <50 IRQ_TYPE_EDGE_RISING>, <51 IRQ_TYPE_EDGE_RISING>; 70 + debounce = <15625>; 71 + pull-up; 72 + }; 73 + }; 74 + }; 75 75 ...
+70
Documentation/devicetree/bindings/input/touchscreen/apple,z2-multitouch.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/input/touchscreen/apple,z2-multitouch.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Apple touchscreens attached using the Z2 protocol 8 + 9 + maintainers: 10 + - Sasha Finkelstein <fnkl.kernel@gmail.com> 11 + 12 + description: A series of touschscreen controllers used in Apple products 13 + 14 + allOf: 15 + - $ref: touchscreen.yaml# 16 + - $ref: /schemas/spi/spi-peripheral-props.yaml# 17 + 18 + properties: 19 + compatible: 20 + enum: 21 + - apple,j293-touchbar 22 + - apple,j493-touchbar 23 + 24 + interrupts: 25 + maxItems: 1 26 + 27 + reset-gpios: 28 + maxItems: 1 29 + 30 + firmware-name: 31 + maxItems: 1 32 + 33 + apple,z2-cal-blob: 34 + $ref: /schemas/types.yaml#/definitions/uint8-array 35 + maxItems: 4096 36 + description: 37 + Calibration blob supplied by the bootloader 38 + 39 + required: 40 + - compatible 41 + - interrupts 42 + - reset-gpios 43 + - firmware-name 44 + - touchscreen-size-x 45 + - touchscreen-size-y 46 + 47 + unevaluatedProperties: false 48 + 49 + examples: 50 + - | 51 + #include <dt-bindings/gpio/gpio.h> 52 + #include <dt-bindings/interrupt-controller/irq.h> 53 + 54 + spi { 55 + #address-cells = <1>; 56 + #size-cells = <0>; 57 + 58 + touchscreen@0 { 59 + compatible = "apple,j293-touchbar"; 60 + reg = <0>; 61 + spi-max-frequency = <11500000>; 62 + reset-gpios = <&pinctrl_ap 139 GPIO_ACTIVE_LOW>; 63 + interrupts-extended = <&pinctrl_ap 194 IRQ_TYPE_EDGE_FALLING>; 64 + firmware-name = "apple/dfrmtfw-j293.bin"; 65 + touchscreen-size-x = <23045>; 66 + touchscreen-size-y = <640>; 67 + }; 68 + }; 69 + 70 + ...
+1
Documentation/devicetree/bindings/input/touchscreen/goodix,gt9916.yaml
··· 19 19 properties: 20 20 compatible: 21 21 enum: 22 + - goodix,gt9897 22 23 - goodix,gt9916 23 24 24 25 reg:
+15 -15
Documentation/devicetree/bindings/input/touchscreen/ti,ads7843.yaml
··· 164 164 #size-cells = <0>; 165 165 166 166 touchscreen@0 { 167 - compatible = "ti,tsc2046"; 168 - reg = <0>; /* CS0 */ 169 - interrupt-parent = <&gpio1>; 170 - interrupts = <8 0>; /* BOOT6 / GPIO 8 */ 171 - pendown-gpio = <&gpio1 8 0>; 172 - spi-max-frequency = <1000000>; 173 - vcc-supply = <&reg_vcc3>; 174 - wakeup-source; 167 + compatible = "ti,tsc2046"; 168 + reg = <0>; /* CS0 */ 169 + interrupt-parent = <&gpio1>; 170 + interrupts = <8 0>; /* BOOT6 / GPIO 8 */ 171 + pendown-gpio = <&gpio1 8 0>; 172 + spi-max-frequency = <1000000>; 173 + vcc-supply = <&reg_vcc3>; 174 + wakeup-source; 175 175 176 - ti,pressure-max = /bits/ 16 <255>; 177 - ti,x-max = /bits/ 16 <8000>; 178 - ti,x-min = /bits/ 16 <0>; 179 - ti,x-plate-ohms = /bits/ 16 <40>; 180 - ti,y-max = /bits/ 16 <4800>; 181 - ti,y-min = /bits/ 16 <0>; 182 - }; 176 + ti,pressure-max = /bits/ 16 <255>; 177 + ti,x-max = /bits/ 16 <8000>; 178 + ti,x-min = /bits/ 16 <0>; 179 + ti,x-plate-ohms = /bits/ 16 <40>; 180 + ti,y-max = /bits/ 16 <4800>; 181 + ti,y-min = /bits/ 16 <0>; 182 + }; 183 183 };
+1 -1
Documentation/devicetree/bindings/power/wakeup-source.txt
··· 23 23 24 24 1. "gpio-key,wakeup" Documentation/devicetree/bindings/input/gpio-keys{,-polled}.txt 25 25 2. "has-tpo" Documentation/devicetree/bindings/rtc/rtc-opal.txt 26 - 3. "linux,wakeup" Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt 26 + 3. "linux,wakeup" Documentation/devicetree/bindings/input/gpio-matrix-keypad.yaml 27 27 Documentation/devicetree/bindings/mfd/tc3589x.txt 28 28 Documentation/devicetree/bindings/input/touchscreen/ti,ads7843.yaml 29 29 4. "linux,keypad-wakeup" Documentation/devicetree/bindings/input/qcom,pm8921-keypad.yaml
+2
MAINTAINERS
··· 2268 2268 F: Documentation/devicetree/bindings/cpufreq/apple,cluster-cpufreq.yaml 2269 2269 F: Documentation/devicetree/bindings/dma/apple,admac.yaml 2270 2270 F: Documentation/devicetree/bindings/i2c/apple,i2c.yaml 2271 + F: Documentation/devicetree/bindings/input/touchscreen/apple,z2-multitouch.yaml 2271 2272 F: Documentation/devicetree/bindings/interrupt-controller/apple,* 2272 2273 F: Documentation/devicetree/bindings/iommu/apple,dart.yaml 2273 2274 F: Documentation/devicetree/bindings/iommu/apple,sart.yaml ··· 2291 2290 F: drivers/pmdomain/apple/ 2292 2291 F: drivers/i2c/busses/i2c-pasemi-core.c 2293 2292 F: drivers/i2c/busses/i2c-pasemi-platform.c 2293 + F: drivers/input/touchscreen/apple_z2.c 2294 2294 F: drivers/iommu/apple-dart.c 2295 2295 F: drivers/iommu/io-pgtable-dart.c 2296 2296 F: drivers/irqchip/irq-apple-aic.c
+1 -2
drivers/input/joystick/walkera0701.c
··· 232 232 goto err_unregister_device; 233 233 } 234 234 235 - hrtimer_init(&w->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 236 - w->timer.function = timer_handler; 235 + hrtimer_setup(&w->timer, timer_handler, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 237 236 238 237 w->input_dev = input_allocate_device(); 239 238 if (!w->input_dev) {
+4 -6
drivers/input/keyboard/gpio_keys.c
··· 590 590 591 591 INIT_DELAYED_WORK(&bdata->work, gpio_keys_gpio_work_func); 592 592 593 - hrtimer_init(&bdata->debounce_timer, 594 - CLOCK_REALTIME, HRTIMER_MODE_REL); 595 - bdata->debounce_timer.function = gpio_keys_debounce_timer; 593 + hrtimer_setup(&bdata->debounce_timer, gpio_keys_debounce_timer, CLOCK_REALTIME, 594 + HRTIMER_MODE_REL); 596 595 597 596 isr = gpio_keys_gpio_isr; 598 597 irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING; ··· 627 628 } 628 629 629 630 bdata->release_delay = button->debounce_interval; 630 - hrtimer_init(&bdata->release_timer, 631 - CLOCK_REALTIME, HRTIMER_MODE_REL_HARD); 632 - bdata->release_timer.function = gpio_keys_irq_timer; 631 + hrtimer_setup(&bdata->release_timer, gpio_keys_irq_timer, CLOCK_REALTIME, 632 + HRTIMER_MODE_REL_HARD); 633 633 634 634 isr = gpio_keys_irq_isr; 635 635 irqflags = 0;
+7 -1
drivers/input/keyboard/matrix_keypad.c
··· 26 26 unsigned int row_shift; 27 27 28 28 unsigned int col_scan_delay_us; 29 + unsigned int all_cols_on_delay_us; 29 30 /* key debounce interval in milli-second */ 30 31 unsigned int debounce_ms; 31 32 bool drive_inactive_cols; ··· 69 68 __activate_col(keypad, col, on); 70 69 71 70 if (on && keypad->col_scan_delay_us) 72 - udelay(keypad->col_scan_delay_us); 71 + fsleep(keypad->col_scan_delay_us); 73 72 } 74 73 75 74 static void activate_all_cols(struct matrix_keypad *keypad, bool on) ··· 78 77 79 78 for (col = 0; col < keypad->num_col_gpios; col++) 80 79 __activate_col(keypad, col, on); 80 + 81 + if (on && keypad->all_cols_on_delay_us) 82 + fsleep(keypad->all_cols_on_delay_us); 81 83 } 82 84 83 85 static bool row_asserted(struct matrix_keypad *keypad, int row) ··· 396 392 &keypad->debounce_ms); 397 393 device_property_read_u32(&pdev->dev, "col-scan-delay-us", 398 394 &keypad->col_scan_delay_us); 395 + device_property_read_u32(&pdev->dev, "all-cols-on-delay-us", 396 + &keypad->all_cols_on_delay_us); 399 397 400 398 err = matrix_keypad_init_gpio(pdev, keypad); 401 399 if (err)
+2 -2
drivers/input/misc/pm8941-pwrkey.c
··· 154 154 if (pwrkey->sw_debounce_time_us) { 155 155 if (ktime_before(ktime_get(), pwrkey->sw_debounce_end_time)) { 156 156 dev_dbg(pwrkey->dev, 157 - "ignoring key event received before debounce end %llu us\n", 158 - pwrkey->sw_debounce_end_time); 157 + "ignoring key event received before debounce end %lld us\n", 158 + ktime_to_us(pwrkey->sw_debounce_end_time)); 159 159 return IRQ_HANDLED; 160 160 } 161 161 }
+2
drivers/input/mouse/synaptics.c
··· 161 161 NULL 162 162 }; 163 163 164 + #ifdef CONFIG_MOUSE_PS2_SYNAPTICS_SMBUS 164 165 static const char * const smbus_pnp_ids[] = { 165 166 /* all of the topbuttonpad_pnp_ids are valid, we just add some extras */ 166 167 "LEN0048", /* X1 Carbon 3 */ ··· 197 196 "SYN3257", /* HP Envy 13-ad105ng */ 198 197 NULL 199 198 }; 199 + #endif 200 200 201 201 static const char * const forcepad_pnp_ids[] = { 202 202 "SYN300D",
-2
drivers/input/rmi4/rmi_f54.c
··· 372 372 .queue_setup = rmi_f54_queue_setup, 373 373 .buf_queue = rmi_f54_buffer_queue, 374 374 .stop_streaming = rmi_f54_stop_streaming, 375 - .wait_prepare = vb2_ops_wait_prepare, 376 - .wait_finish = vb2_ops_wait_finish, 377 375 }; 378 376 379 377 static const struct vb2_queue rmi_f54_queue = {
+13
drivers/input/touchscreen/Kconfig
··· 103 103 To compile this driver as a module, choose M here: the 104 104 module will be called resistive-adc-touch.ko. 105 105 106 + config TOUCHSCREEN_APPLE_Z2 107 + tristate "Apple Z2 touchscreens" 108 + default ARCH_APPLE 109 + depends on SPI && (ARCH_APPLE || COMPILE_TEST) 110 + help 111 + Say Y here if you have an ARM Apple device with 112 + a touchscreen or a touchbar. 113 + 114 + If unsure, say N. 115 + 116 + To compile this driver as a module, choose M here: the 117 + module will be called apple_z2. 118 + 106 119 config TOUCHSCREEN_AR1021_I2C 107 120 tristate "Microchip AR1020/1021 i2c touchscreen" 108 121 depends on I2C && OF
+1
drivers/input/touchscreen/Makefile
··· 15 15 obj-$(CONFIG_TOUCHSCREEN_AD7879_SPI) += ad7879-spi.o 16 16 obj-$(CONFIG_TOUCHSCREEN_ADC) += resistive-adc-touch.o 17 17 obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o 18 + obj-$(CONFIG_TOUCHSCREEN_APPLE_Z2) += apple_z2.o 18 19 obj-$(CONFIG_TOUCHSCREEN_AR1021_I2C) += ar1021_i2c.o 19 20 obj-$(CONFIG_TOUCHSCREEN_ATMEL_MXT) += atmel_mxt_ts.o 20 21 obj-$(CONFIG_TOUCHSCREEN_AUO_PIXCIR) += auo-pixcir-ts.o
+477
drivers/input/touchscreen/apple_z2.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Apple Z2 touchscreen driver 4 + * 5 + * Copyright (C) The Asahi Linux Contributors 6 + */ 7 + 8 + #include <linux/delay.h> 9 + #include <linux/firmware.h> 10 + #include <linux/input.h> 11 + #include <linux/input/mt.h> 12 + #include <linux/input/touchscreen.h> 13 + #include <linux/interrupt.h> 14 + #include <linux/module.h> 15 + #include <linux/of.h> 16 + #include <linux/spi/spi.h> 17 + #include <linux/unaligned.h> 18 + 19 + #define APPLE_Z2_NUM_FINGERS_OFFSET 16 20 + #define APPLE_Z2_FINGERS_OFFSET 24 21 + #define APPLE_Z2_TOUCH_STARTED 3 22 + #define APPLE_Z2_TOUCH_MOVED 4 23 + #define APPLE_Z2_CMD_READ_INTERRUPT_DATA 0xEB 24 + #define APPLE_Z2_HBPP_CMD_BLOB 0x3001 25 + #define APPLE_Z2_FW_MAGIC 0x5746325A 26 + #define LOAD_COMMAND_INIT_PAYLOAD 0 27 + #define LOAD_COMMAND_SEND_BLOB 1 28 + #define LOAD_COMMAND_SEND_CALIBRATION 2 29 + #define CAL_PROP_NAME "apple,z2-cal-blob" 30 + 31 + struct apple_z2 { 32 + struct spi_device *spidev; 33 + struct gpio_desc *reset_gpio; 34 + struct input_dev *input_dev; 35 + struct completion boot_irq; 36 + bool booted; 37 + int index_parity; 38 + struct touchscreen_properties props; 39 + const char *fw_name; 40 + u8 *tx_buf; 41 + u8 *rx_buf; 42 + }; 43 + 44 + struct apple_z2_finger { 45 + u8 finger; 46 + u8 state; 47 + __le16 unknown2; 48 + __le16 abs_x; 49 + __le16 abs_y; 50 + __le16 rel_x; 51 + __le16 rel_y; 52 + __le16 tool_major; 53 + __le16 tool_minor; 54 + __le16 orientation; 55 + __le16 touch_major; 56 + __le16 touch_minor; 57 + __le16 unused[2]; 58 + __le16 pressure; 59 + __le16 multi; 60 + } __packed; 61 + 62 + struct apple_z2_hbpp_blob_hdr { 63 + __le16 cmd; 64 + __le16 len; 65 + __le32 addr; 66 + __le16 checksum; 67 + }; 68 + 69 + struct apple_z2_fw_hdr { 70 + __le32 magic; 71 + __le32 version; 72 + }; 73 + 74 + struct apple_z2_read_interrupt_cmd { 75 + u8 cmd; 76 + u8 counter; 77 + u8 unused[12]; 78 + __le16 checksum; 79 + }; 80 + 81 + static void apple_z2_parse_touches(struct apple_z2 *z2, 82 + const u8 *msg, size_t msg_len) 83 + { 84 + int i; 85 + int nfingers; 86 + int slot; 87 + int slot_valid; 88 + struct apple_z2_finger *fingers; 89 + 90 + if (msg_len <= APPLE_Z2_NUM_FINGERS_OFFSET) 91 + return; 92 + nfingers = msg[APPLE_Z2_NUM_FINGERS_OFFSET]; 93 + fingers = (struct apple_z2_finger *)(msg + APPLE_Z2_FINGERS_OFFSET); 94 + for (i = 0; i < nfingers; i++) { 95 + slot = input_mt_get_slot_by_key(z2->input_dev, fingers[i].finger); 96 + if (slot < 0) { 97 + dev_warn(&z2->spidev->dev, "unable to get slot for finger\n"); 98 + continue; 99 + } 100 + slot_valid = fingers[i].state == APPLE_Z2_TOUCH_STARTED || 101 + fingers[i].state == APPLE_Z2_TOUCH_MOVED; 102 + input_mt_slot(z2->input_dev, slot); 103 + if (!input_mt_report_slot_state(z2->input_dev, MT_TOOL_FINGER, slot_valid)) 104 + continue; 105 + touchscreen_report_pos(z2->input_dev, &z2->props, 106 + le16_to_cpu(fingers[i].abs_x), 107 + le16_to_cpu(fingers[i].abs_y), 108 + true); 109 + input_report_abs(z2->input_dev, ABS_MT_WIDTH_MAJOR, 110 + le16_to_cpu(fingers[i].tool_major)); 111 + input_report_abs(z2->input_dev, ABS_MT_WIDTH_MINOR, 112 + le16_to_cpu(fingers[i].tool_minor)); 113 + input_report_abs(z2->input_dev, ABS_MT_ORIENTATION, 114 + le16_to_cpu(fingers[i].orientation)); 115 + input_report_abs(z2->input_dev, ABS_MT_TOUCH_MAJOR, 116 + le16_to_cpu(fingers[i].touch_major)); 117 + input_report_abs(z2->input_dev, ABS_MT_TOUCH_MINOR, 118 + le16_to_cpu(fingers[i].touch_minor)); 119 + } 120 + input_mt_sync_frame(z2->input_dev); 121 + input_sync(z2->input_dev); 122 + } 123 + 124 + static int apple_z2_read_packet(struct apple_z2 *z2) 125 + { 126 + struct apple_z2_read_interrupt_cmd *len_cmd = (void *)z2->tx_buf; 127 + struct spi_transfer xfer; 128 + int error; 129 + size_t pkt_len; 130 + 131 + memset(&xfer, 0, sizeof(xfer)); 132 + len_cmd->cmd = APPLE_Z2_CMD_READ_INTERRUPT_DATA; 133 + len_cmd->counter = z2->index_parity + 1; 134 + len_cmd->checksum = 135 + cpu_to_le16(APPLE_Z2_CMD_READ_INTERRUPT_DATA + len_cmd->counter); 136 + z2->index_parity = !z2->index_parity; 137 + xfer.tx_buf = z2->tx_buf; 138 + xfer.rx_buf = z2->rx_buf; 139 + xfer.len = sizeof(*len_cmd); 140 + 141 + error = spi_sync_transfer(z2->spidev, &xfer, 1); 142 + if (error) 143 + return error; 144 + 145 + pkt_len = (get_unaligned_le16(z2->rx_buf + 1) + 8) & 0xfffffffc; 146 + 147 + error = spi_read(z2->spidev, z2->rx_buf, pkt_len); 148 + if (error) 149 + return error; 150 + 151 + apple_z2_parse_touches(z2, z2->rx_buf + 5, pkt_len - 5); 152 + 153 + return 0; 154 + } 155 + 156 + static irqreturn_t apple_z2_irq(int irq, void *data) 157 + { 158 + struct apple_z2 *z2 = data; 159 + 160 + if (unlikely(!z2->booted)) 161 + complete(&z2->boot_irq); 162 + else 163 + apple_z2_read_packet(z2); 164 + 165 + return IRQ_HANDLED; 166 + } 167 + 168 + /* Build calibration blob, caller is responsible for freeing the blob data. */ 169 + static const u8 *apple_z2_build_cal_blob(struct apple_z2 *z2, 170 + u32 address, size_t *size) 171 + { 172 + u8 *cal_data; 173 + int cal_size; 174 + size_t blob_size; 175 + u32 checksum; 176 + u16 checksum_hdr; 177 + int i; 178 + struct apple_z2_hbpp_blob_hdr *hdr; 179 + int error; 180 + 181 + if (!device_property_present(&z2->spidev->dev, CAL_PROP_NAME)) 182 + return NULL; 183 + 184 + cal_size = device_property_count_u8(&z2->spidev->dev, CAL_PROP_NAME); 185 + if (cal_size < 0) 186 + return ERR_PTR(cal_size); 187 + 188 + blob_size = sizeof(struct apple_z2_hbpp_blob_hdr) + cal_size + sizeof(__le32); 189 + u8 *blob_data __free(kfree) = kzalloc(blob_size, GFP_KERNEL); 190 + if (!blob_data) 191 + return ERR_PTR(-ENOMEM); 192 + 193 + hdr = (struct apple_z2_hbpp_blob_hdr *)blob_data; 194 + hdr->cmd = cpu_to_le16(APPLE_Z2_HBPP_CMD_BLOB); 195 + hdr->len = cpu_to_le16(round_up(cal_size, 4) / 4); 196 + hdr->addr = cpu_to_le32(address); 197 + 198 + checksum_hdr = 0; 199 + for (i = 2; i < 8; i++) 200 + checksum_hdr += blob_data[i]; 201 + hdr->checksum = cpu_to_le16(checksum_hdr); 202 + 203 + cal_data = blob_data + sizeof(struct apple_z2_hbpp_blob_hdr); 204 + error = device_property_read_u8_array(&z2->spidev->dev, CAL_PROP_NAME, 205 + cal_data, cal_size); 206 + if (error) 207 + return ERR_PTR(error); 208 + 209 + checksum = 0; 210 + for (i = 0; i < cal_size; i++) 211 + checksum += cal_data[i]; 212 + put_unaligned_le32(checksum, cal_data + cal_size); 213 + 214 + *size = blob_size; 215 + return no_free_ptr(blob_data); 216 + } 217 + 218 + static int apple_z2_send_firmware_blob(struct apple_z2 *z2, const u8 *data, 219 + u32 size, bool init) 220 + { 221 + struct spi_message msg; 222 + struct spi_transfer blob_xfer, ack_xfer; 223 + int error; 224 + 225 + z2->tx_buf[0] = 0x1a; 226 + z2->tx_buf[1] = 0xa1; 227 + 228 + spi_message_init(&msg); 229 + memset(&blob_xfer, 0, sizeof(blob_xfer)); 230 + memset(&ack_xfer, 0, sizeof(ack_xfer)); 231 + 232 + blob_xfer.tx_buf = data; 233 + blob_xfer.len = size; 234 + blob_xfer.bits_per_word = init ? 8 : 16; 235 + spi_message_add_tail(&blob_xfer, &msg); 236 + 237 + ack_xfer.tx_buf = z2->tx_buf; 238 + ack_xfer.len = 2; 239 + spi_message_add_tail(&ack_xfer, &msg); 240 + 241 + reinit_completion(&z2->boot_irq); 242 + error = spi_sync(z2->spidev, &msg); 243 + if (error) 244 + return error; 245 + 246 + /* Irq only happens sometimes, but the thing boots reliably nonetheless */ 247 + wait_for_completion_timeout(&z2->boot_irq, msecs_to_jiffies(20)); 248 + 249 + return 0; 250 + } 251 + 252 + static int apple_z2_upload_firmware(struct apple_z2 *z2) 253 + { 254 + const struct apple_z2_fw_hdr *fw_hdr; 255 + size_t fw_idx = sizeof(struct apple_z2_fw_hdr); 256 + int error; 257 + u32 load_cmd; 258 + u32 address; 259 + bool init; 260 + size_t size; 261 + 262 + const struct firmware *fw __free(firmware) = NULL; 263 + error = request_firmware(&fw, z2->fw_name, &z2->spidev->dev); 264 + if (error) { 265 + dev_err(&z2->spidev->dev, "unable to load firmware\n"); 266 + return error; 267 + } 268 + 269 + fw_hdr = (const struct apple_z2_fw_hdr *)fw->data; 270 + if (le32_to_cpu(fw_hdr->magic) != APPLE_Z2_FW_MAGIC || le32_to_cpu(fw_hdr->version) != 1) { 271 + dev_err(&z2->spidev->dev, "invalid firmware header\n"); 272 + return -EINVAL; 273 + } 274 + 275 + /* 276 + * This will interrupt the upload half-way if the file is malformed 277 + * As the device has no non-volatile storage to corrupt, and gets reset 278 + * on boot anyway, this is fine. 279 + */ 280 + while (fw_idx < fw->size) { 281 + if (fw->size - fw_idx < 8) { 282 + dev_err(&z2->spidev->dev, "firmware malformed\n"); 283 + return -EINVAL; 284 + } 285 + 286 + load_cmd = le32_to_cpup((__force __le32 *)(fw->data + fw_idx)); 287 + fw_idx += sizeof(u32); 288 + if (load_cmd == LOAD_COMMAND_INIT_PAYLOAD || load_cmd == LOAD_COMMAND_SEND_BLOB) { 289 + size = le32_to_cpup((__force __le32 *)(fw->data + fw_idx)); 290 + fw_idx += sizeof(u32); 291 + if (fw->size - fw_idx < size) { 292 + dev_err(&z2->spidev->dev, "firmware malformed\n"); 293 + return -EINVAL; 294 + } 295 + init = load_cmd == LOAD_COMMAND_INIT_PAYLOAD; 296 + error = apple_z2_send_firmware_blob(z2, fw->data + fw_idx, 297 + size, init); 298 + if (error) 299 + return error; 300 + fw_idx += size; 301 + } else if (load_cmd == LOAD_COMMAND_SEND_CALIBRATION) { 302 + address = le32_to_cpup((__force __le32 *)(fw->data + fw_idx)); 303 + fw_idx += sizeof(u32); 304 + 305 + const u8 *data __free(kfree) = 306 + apple_z2_build_cal_blob(z2, address, &size); 307 + if (IS_ERR(data)) 308 + return PTR_ERR(data); 309 + 310 + if (data) { 311 + error = apple_z2_send_firmware_blob(z2, data, size, false); 312 + if (error) 313 + return error; 314 + } 315 + } else { 316 + dev_err(&z2->spidev->dev, "firmware malformed\n"); 317 + return -EINVAL; 318 + } 319 + fw_idx = round_up(fw_idx, 4); 320 + } 321 + 322 + 323 + z2->booted = true; 324 + apple_z2_read_packet(z2); 325 + return 0; 326 + } 327 + 328 + static int apple_z2_boot(struct apple_z2 *z2) 329 + { 330 + int error; 331 + 332 + reinit_completion(&z2->boot_irq); 333 + enable_irq(z2->spidev->irq); 334 + gpiod_set_value(z2->reset_gpio, 0); 335 + if (!wait_for_completion_timeout(&z2->boot_irq, msecs_to_jiffies(20))) 336 + return -ETIMEDOUT; 337 + 338 + error = apple_z2_upload_firmware(z2); 339 + if (error) { 340 + gpiod_set_value(z2->reset_gpio, 1); 341 + disable_irq(z2->spidev->irq); 342 + return error; 343 + } 344 + 345 + return 0; 346 + } 347 + 348 + static int apple_z2_probe(struct spi_device *spi) 349 + { 350 + struct device *dev = &spi->dev; 351 + struct apple_z2 *z2; 352 + int error; 353 + 354 + z2 = devm_kzalloc(dev, sizeof(*z2), GFP_KERNEL); 355 + if (!z2) 356 + return -ENOMEM; 357 + 358 + z2->tx_buf = devm_kzalloc(dev, sizeof(struct apple_z2_read_interrupt_cmd), GFP_KERNEL); 359 + if (!z2->tx_buf) 360 + return -ENOMEM; 361 + /* 4096 will end up being rounded up to 8192 due to devres header */ 362 + z2->rx_buf = devm_kzalloc(dev, 4000, GFP_KERNEL); 363 + if (!z2->rx_buf) 364 + return -ENOMEM; 365 + 366 + z2->spidev = spi; 367 + init_completion(&z2->boot_irq); 368 + spi_set_drvdata(spi, z2); 369 + 370 + /* Reset the device on boot */ 371 + z2->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); 372 + if (IS_ERR(z2->reset_gpio)) 373 + return dev_err_probe(dev, PTR_ERR(z2->reset_gpio), "unable to get reset\n"); 374 + 375 + error = devm_request_threaded_irq(dev, z2->spidev->irq, NULL, apple_z2_irq, 376 + IRQF_ONESHOT | IRQF_NO_AUTOEN, 377 + "apple-z2-irq", z2); 378 + if (error) 379 + return dev_err_probe(dev, error, "unable to request irq\n"); 380 + 381 + error = device_property_read_string(dev, "firmware-name", &z2->fw_name); 382 + if (error) 383 + return dev_err_probe(dev, error, "unable to get firmware name\n"); 384 + 385 + z2->input_dev = devm_input_allocate_device(dev); 386 + if (!z2->input_dev) 387 + return -ENOMEM; 388 + 389 + z2->input_dev->name = (char *)spi_get_device_id(spi)->driver_data; 390 + z2->input_dev->phys = "apple_z2"; 391 + z2->input_dev->id.bustype = BUS_SPI; 392 + 393 + /* Allocate the axes before setting from DT */ 394 + input_set_abs_params(z2->input_dev, ABS_MT_POSITION_X, 0, 0, 0, 0); 395 + input_set_abs_params(z2->input_dev, ABS_MT_POSITION_Y, 0, 0, 0, 0); 396 + touchscreen_parse_properties(z2->input_dev, true, &z2->props); 397 + input_abs_set_res(z2->input_dev, ABS_MT_POSITION_X, 100); 398 + input_abs_set_res(z2->input_dev, ABS_MT_POSITION_Y, 100); 399 + input_set_abs_params(z2->input_dev, ABS_MT_WIDTH_MAJOR, 0, 65535, 0, 0); 400 + input_set_abs_params(z2->input_dev, ABS_MT_WIDTH_MINOR, 0, 65535, 0, 0); 401 + input_set_abs_params(z2->input_dev, ABS_MT_TOUCH_MAJOR, 0, 65535, 0, 0); 402 + input_set_abs_params(z2->input_dev, ABS_MT_TOUCH_MINOR, 0, 65535, 0, 0); 403 + input_set_abs_params(z2->input_dev, ABS_MT_ORIENTATION, -32768, 32767, 0, 0); 404 + 405 + error = input_mt_init_slots(z2->input_dev, 256, INPUT_MT_DIRECT); 406 + if (error) 407 + return dev_err_probe(dev, error, "unable to initialize multitouch slots\n"); 408 + 409 + error = input_register_device(z2->input_dev); 410 + if (error) 411 + return dev_err_probe(dev, error, "unable to register input device\n"); 412 + 413 + /* Wait for device reset to finish */ 414 + usleep_range(5000, 10000); 415 + error = apple_z2_boot(z2); 416 + if (error) 417 + return error; 418 + 419 + return 0; 420 + } 421 + 422 + static void apple_z2_shutdown(struct spi_device *spi) 423 + { 424 + struct apple_z2 *z2 = spi_get_drvdata(spi); 425 + 426 + disable_irq(z2->spidev->irq); 427 + gpiod_direction_output(z2->reset_gpio, 1); 428 + z2->booted = false; 429 + } 430 + 431 + static int apple_z2_suspend(struct device *dev) 432 + { 433 + apple_z2_shutdown(to_spi_device(dev)); 434 + 435 + return 0; 436 + } 437 + 438 + static int apple_z2_resume(struct device *dev) 439 + { 440 + struct apple_z2 *z2 = spi_get_drvdata(to_spi_device(dev)); 441 + 442 + return apple_z2_boot(z2); 443 + } 444 + 445 + static DEFINE_SIMPLE_DEV_PM_OPS(apple_z2_pm, apple_z2_suspend, apple_z2_resume); 446 + 447 + static const struct of_device_id apple_z2_of_match[] = { 448 + { .compatible = "apple,j293-touchbar" }, 449 + { .compatible = "apple,j493-touchbar" }, 450 + {} 451 + }; 452 + MODULE_DEVICE_TABLE(of, apple_z2_of_match); 453 + 454 + static struct spi_device_id apple_z2_of_id[] = { 455 + { .name = "j293-touchbar", .driver_data = (kernel_ulong_t)"MacBookPro17,1 Touch Bar" }, 456 + { .name = "j493-touchbar", .driver_data = (kernel_ulong_t)"Mac14,7 Touch Bar" }, 457 + {} 458 + }; 459 + MODULE_DEVICE_TABLE(spi, apple_z2_of_id); 460 + 461 + static struct spi_driver apple_z2_driver = { 462 + .driver = { 463 + .name = "apple-z2", 464 + .pm = pm_sleep_ptr(&apple_z2_pm), 465 + .of_match_table = apple_z2_of_match, 466 + .probe_type = PROBE_PREFER_ASYNCHRONOUS, 467 + }, 468 + .id_table = apple_z2_of_id, 469 + .probe = apple_z2_probe, 470 + .remove = apple_z2_shutdown, 471 + }; 472 + 473 + module_spi_driver(apple_z2_driver); 474 + 475 + MODULE_LICENSE("GPL"); 476 + MODULE_FIRMWARE("apple/dfrmtfw-*.bin"); 477 + MODULE_DESCRIPTION("Apple Z2 touchscreens driver");
-2
drivers/input/touchscreen/atmel_mxt_ts.c
··· 2535 2535 static const struct vb2_ops mxt_queue_ops = { 2536 2536 .queue_setup = mxt_queue_setup, 2537 2537 .buf_queue = mxt_buffer_queue, 2538 - .wait_prepare = vb2_ops_wait_prepare, 2539 - .wait_finish = vb2_ops_wait_finish, 2540 2538 }; 2541 2539 2542 2540 static const struct vb2_queue mxt_queue = {
+15 -1
drivers/input/touchscreen/goodix_berlin.h
··· 12 12 13 13 #include <linux/pm.h> 14 14 15 + #define GOODIX_BERLIN_FW_VERSION_INFO_ADDR_A 0x1000C 16 + #define GOODIX_BERLIN_FW_VERSION_INFO_ADDR_D 0x10014 17 + 18 + #define GOODIX_BERLIN_IC_INFO_ADDR_A 0x10068 19 + #define GOODIX_BERLIN_IC_INFO_ADDR_D 0x10070 20 + 21 + struct goodix_berlin_ic_data { 22 + int fw_version_info_addr; 23 + int ic_info_addr; 24 + ssize_t read_dummy_len; 25 + ssize_t read_prefix_len; 26 + }; 27 + 15 28 struct device; 16 29 struct input_id; 17 30 struct regmap; 18 31 19 32 int goodix_berlin_probe(struct device *dev, int irq, const struct input_id *id, 20 - struct regmap *regmap); 33 + struct regmap *regmap, 34 + const struct goodix_berlin_ic_data *ic_data); 21 35 22 36 extern const struct dev_pm_ops goodix_berlin_pm_ops; 23 37 extern const struct attribute_group *goodix_berlin_groups[];
+12 -9
drivers/input/touchscreen/goodix_berlin_core.c
··· 12 12 * to the previous generations. 13 13 * 14 14 * Currently the driver only handles Multitouch events with already 15 - * programmed firmware and "config" for "Revision D" Berlin IC. 15 + * programmed firmware and "config" for "Revision A/D" Berlin IC. 16 16 * 17 17 * Support is missing for: 18 18 * - ESD Management ··· 20 20 * - "Config" update/flashing 21 21 * - Stylus Events 22 22 * - Gesture Events 23 - * - Support for older revisions (A & B) 23 + * - Support for revision B 24 24 */ 25 25 26 26 #include <linux/bitfield.h> ··· 28 28 #include <linux/input.h> 29 29 #include <linux/input/mt.h> 30 30 #include <linux/input/touchscreen.h> 31 + #include <linux/property.h> 31 32 #include <linux/regmap.h> 32 33 #include <linux/regulator/consumer.h> 33 34 #include <linux/sizes.h> ··· 54 53 55 54 #define GOODIX_BERLIN_DEV_CONFIRM_VAL 0xAA 56 55 #define GOODIX_BERLIN_BOOTOPTION_ADDR 0x10000 57 - #define GOODIX_BERLIN_FW_VERSION_INFO_ADDR 0x10014 58 56 59 57 #define GOODIX_BERLIN_IC_INFO_MAX_LEN SZ_1K 60 - #define GOODIX_BERLIN_IC_INFO_ADDR 0x10070 61 58 62 59 #define GOODIX_BERLIN_CHECKSUM_SIZE sizeof(u16) 63 60 ··· 173 174 174 175 /* Runtime parameters extracted from IC_INFO buffer */ 175 176 u32 touch_data_addr; 177 + 178 + const struct goodix_berlin_ic_data *ic_data; 176 179 177 180 struct goodix_berlin_event event; 178 181 }; ··· 300 299 { 301 300 int error; 302 301 303 - error = regmap_raw_read(cd->regmap, GOODIX_BERLIN_FW_VERSION_INFO_ADDR, 302 + error = regmap_raw_read(cd->regmap, cd->ic_data->fw_version_info_addr, 304 303 &cd->fw_version, sizeof(cd->fw_version)); 305 304 if (error) { 306 305 dev_err(cd->dev, "error reading fw version, %d\n", error); ··· 368 367 if (!afe_data) 369 368 return -ENOMEM; 370 369 371 - error = regmap_raw_read(cd->regmap, GOODIX_BERLIN_IC_INFO_ADDR, 370 + error = regmap_raw_read(cd->regmap, cd->ic_data->ic_info_addr, 372 371 &length_raw, sizeof(length_raw)); 373 372 if (error) { 374 373 dev_err(cd->dev, "failed get ic info length, %d\n", error); ··· 381 380 return -EINVAL; 382 381 } 383 382 384 - error = regmap_raw_read(cd->regmap, GOODIX_BERLIN_IC_INFO_ADDR, 385 - afe_data, length); 383 + error = regmap_raw_read(cd->regmap, cd->ic_data->ic_info_addr, afe_data, 384 + length); 386 385 if (error) { 387 386 dev_err(cd->dev, "failed get ic info data, %d\n", error); 388 387 return error; ··· 717 716 EXPORT_SYMBOL_GPL(goodix_berlin_groups); 718 717 719 718 int goodix_berlin_probe(struct device *dev, int irq, const struct input_id *id, 720 - struct regmap *regmap) 719 + struct regmap *regmap, 720 + const struct goodix_berlin_ic_data *ic_data) 721 721 { 722 722 struct goodix_berlin_core *cd; 723 723 int error; ··· 735 733 cd->dev = dev; 736 734 cd->regmap = regmap; 737 735 cd->irq = irq; 736 + cd->ic_data = ic_data; 738 737 739 738 cd->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); 740 739 if (IS_ERR(cd->reset_gpio))
+11 -3
drivers/input/touchscreen/goodix_berlin_i2c.c
··· 31 31 32 32 static int goodix_berlin_i2c_probe(struct i2c_client *client) 33 33 { 34 + const struct goodix_berlin_ic_data *ic_data = 35 + i2c_get_match_data(client); 34 36 struct regmap *regmap; 35 37 int error; 36 38 ··· 41 39 return PTR_ERR(regmap); 42 40 43 41 error = goodix_berlin_probe(&client->dev, client->irq, 44 - &goodix_berlin_i2c_input_id, regmap); 42 + &goodix_berlin_i2c_input_id, regmap, 43 + ic_data); 45 44 if (error) 46 45 return error; 47 46 48 47 return 0; 49 48 } 50 49 50 + static const struct goodix_berlin_ic_data gt9916_data = { 51 + .fw_version_info_addr = GOODIX_BERLIN_FW_VERSION_INFO_ADDR_D, 52 + .ic_info_addr = GOODIX_BERLIN_IC_INFO_ADDR_D, 53 + }; 54 + 51 55 static const struct i2c_device_id goodix_berlin_i2c_id[] = { 52 - { "gt9916" }, 56 + { .name = "gt9916", .driver_data = (long)&gt9916_data }, 53 57 { } 54 58 }; 55 59 56 60 MODULE_DEVICE_TABLE(i2c, goodix_berlin_i2c_id); 57 61 58 62 static const struct of_device_id goodix_berlin_i2c_of_match[] = { 59 - { .compatible = "goodix,gt9916", }, 63 + { .compatible = "goodix,gt9916", .data = &gt9916_data }, 60 64 { } 61 65 }; 62 66 MODULE_DEVICE_TABLE(of, goodix_berlin_i2c_of_match);
+35 -13
drivers/input/touchscreen/goodix_berlin_spi.c
··· 18 18 19 19 #define GOODIX_BERLIN_SPI_TRANS_PREFIX_LEN 1 20 20 #define GOODIX_BERLIN_REGISTER_WIDTH 4 21 - #define GOODIX_BERLIN_SPI_READ_DUMMY_LEN 3 22 - #define GOODIX_BERLIN_SPI_READ_PREFIX_LEN (GOODIX_BERLIN_SPI_TRANS_PREFIX_LEN + \ 21 + #define GOODIX_BERLIN_SPI_READ_DUMMY_LEN_A 4 22 + #define GOODIX_BERLIN_SPI_READ_DUMMY_LEN_D 3 23 + #define GOODIX_BERLIN_SPI_READ_PREFIX_LEN_A (GOODIX_BERLIN_SPI_TRANS_PREFIX_LEN + \ 23 24 GOODIX_BERLIN_REGISTER_WIDTH + \ 24 - GOODIX_BERLIN_SPI_READ_DUMMY_LEN) 25 + GOODIX_BERLIN_SPI_READ_DUMMY_LEN_A) 26 + #define GOODIX_BERLIN_SPI_READ_PREFIX_LEN_D (GOODIX_BERLIN_SPI_TRANS_PREFIX_LEN + \ 27 + GOODIX_BERLIN_REGISTER_WIDTH + \ 28 + GOODIX_BERLIN_SPI_READ_DUMMY_LEN_D) 25 29 #define GOODIX_BERLIN_SPI_WRITE_PREFIX_LEN (GOODIX_BERLIN_SPI_TRANS_PREFIX_LEN + \ 26 30 GOODIX_BERLIN_REGISTER_WIDTH) 27 31 ··· 37 33 size_t val_size) 38 34 { 39 35 struct spi_device *spi = context; 36 + const struct goodix_berlin_ic_data *ic_data = spi_get_device_match_data(spi); 40 37 struct spi_transfer xfers; 41 38 struct spi_message spi_msg; 42 39 const u32 *reg = reg_buf; /* reg is stored as native u32 at start of buffer */ ··· 47 42 return -EINVAL; 48 43 49 44 u8 *buf __free(kfree) = 50 - kzalloc(GOODIX_BERLIN_SPI_READ_PREFIX_LEN + val_size, 51 - GFP_KERNEL); 45 + kzalloc(ic_data->read_prefix_len + val_size, GFP_KERNEL); 52 46 if (!buf) 53 47 return -ENOMEM; 54 48 55 49 spi_message_init(&spi_msg); 56 50 memset(&xfers, 0, sizeof(xfers)); 57 51 58 - /* buffer format: 0xF1 + addr(4bytes) + dummy(3bytes) + data */ 52 + /* buffer format: 0xF1 + addr(4bytes) + dummy(3/4bytes) + data */ 59 53 buf[0] = GOODIX_BERLIN_SPI_READ_FLAG; 60 54 put_unaligned_be32(*reg, buf + GOODIX_BERLIN_SPI_TRANS_PREFIX_LEN); 61 55 memset(buf + GOODIX_BERLIN_SPI_TRANS_PREFIX_LEN + GOODIX_BERLIN_REGISTER_WIDTH, 62 - 0xff, GOODIX_BERLIN_SPI_READ_DUMMY_LEN); 56 + 0xff, ic_data->read_dummy_len); 63 57 64 58 xfers.tx_buf = buf; 65 59 xfers.rx_buf = buf; 66 - xfers.len = GOODIX_BERLIN_SPI_READ_PREFIX_LEN + val_size; 60 + xfers.len = ic_data->read_prefix_len + val_size; 67 61 xfers.cs_change = 0; 68 62 spi_message_add_tail(&xfers, &spi_msg); 69 63 ··· 72 68 return error; 73 69 } 74 70 75 - memcpy(val_buf, buf + GOODIX_BERLIN_SPI_READ_PREFIX_LEN, val_size); 71 + memcpy(val_buf, buf + ic_data->read_prefix_len, val_size); 76 72 return error; 77 73 } 78 74 ··· 127 123 128 124 static int goodix_berlin_spi_probe(struct spi_device *spi) 129 125 { 126 + const struct goodix_berlin_ic_data *ic_data = spi_get_device_match_data(spi); 130 127 struct regmap_config regmap_config; 131 128 struct regmap *regmap; 132 129 size_t max_size; ··· 142 137 max_size = spi_max_transfer_size(spi); 143 138 144 139 regmap_config = goodix_berlin_spi_regmap_conf; 145 - regmap_config.max_raw_read = max_size - GOODIX_BERLIN_SPI_READ_PREFIX_LEN; 140 + regmap_config.max_raw_read = max_size - ic_data->read_prefix_len; 146 141 regmap_config.max_raw_write = max_size - GOODIX_BERLIN_SPI_WRITE_PREFIX_LEN; 147 142 148 143 regmap = devm_regmap_init(&spi->dev, NULL, spi, &regmap_config); ··· 150 145 return PTR_ERR(regmap); 151 146 152 147 error = goodix_berlin_probe(&spi->dev, spi->irq, 153 - &goodix_berlin_spi_input_id, regmap); 148 + &goodix_berlin_spi_input_id, regmap, 149 + ic_data); 154 150 if (error) 155 151 return error; 156 152 157 153 return 0; 158 154 } 159 155 156 + static const struct goodix_berlin_ic_data gt9897_data = { 157 + .fw_version_info_addr = GOODIX_BERLIN_FW_VERSION_INFO_ADDR_A, 158 + .ic_info_addr = GOODIX_BERLIN_IC_INFO_ADDR_A, 159 + .read_dummy_len = GOODIX_BERLIN_SPI_READ_DUMMY_LEN_A, 160 + .read_prefix_len = GOODIX_BERLIN_SPI_READ_PREFIX_LEN_A, 161 + }; 162 + 163 + static const struct goodix_berlin_ic_data gt9916_data = { 164 + .fw_version_info_addr = GOODIX_BERLIN_FW_VERSION_INFO_ADDR_D, 165 + .ic_info_addr = GOODIX_BERLIN_IC_INFO_ADDR_D, 166 + .read_dummy_len = GOODIX_BERLIN_SPI_READ_DUMMY_LEN_D, 167 + .read_prefix_len = GOODIX_BERLIN_SPI_READ_PREFIX_LEN_D, 168 + }; 169 + 160 170 static const struct spi_device_id goodix_berlin_spi_ids[] = { 161 - { "gt9916" }, 171 + { .name = "gt9897", .driver_data = (long)&gt9897_data }, 172 + { .name = "gt9916", .driver_data = (long)&gt9916_data }, 162 173 { }, 163 174 }; 164 175 MODULE_DEVICE_TABLE(spi, goodix_berlin_spi_ids); 165 176 166 177 static const struct of_device_id goodix_berlin_spi_of_match[] = { 167 - { .compatible = "goodix,gt9916", }, 178 + { .compatible = "goodix,gt9897", .data = &gt9897_data }, 179 + { .compatible = "goodix,gt9916", .data = &gt9916_data }, 168 180 { } 169 181 }; 170 182 MODULE_DEVICE_TABLE(of, goodix_berlin_spi_of_match);
-2
drivers/input/touchscreen/sur40.c
··· 1108 1108 .buf_queue = sur40_buffer_queue, 1109 1109 .start_streaming = sur40_start_streaming, 1110 1110 .stop_streaming = sur40_stop_streaming, 1111 - .wait_prepare = vb2_ops_wait_prepare, 1112 - .wait_finish = vb2_ops_wait_finish, 1113 1111 }; 1114 1112 1115 1113 static const struct vb2_queue sur40_queue = {