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

Configure Feed

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

Merge branch 'next' into for-linus

Prepare input updates for 5.7 merge window.

+655 -214
-77
Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
··· 1 - FocalTech EDT-FT5x06 Polytouch driver 2 - ===================================== 3 - 4 - There are 5 variants of the chip for various touch panel sizes 5 - FT5206GE1 2.8" .. 3.8" 6 - FT5306DE4 4.3" .. 7" 7 - FT5406EE8 7" .. 8.9" 8 - FT5506EEG 7" .. 8.9" 9 - FT5726NEI 5.7” .. 11.6" 10 - 11 - The software interface is identical for all those chips, so that 12 - currently there is no need for the driver to distinguish between the 13 - different chips. Nevertheless distinct compatible strings are used so 14 - that a distinction can be added if necessary without changing the DT 15 - bindings. 16 - 17 - 18 - Required properties: 19 - - compatible: "edt,edt-ft5206" 20 - or: "edt,edt-ft5306" 21 - or: "edt,edt-ft5406" 22 - or: "edt,edt-ft5506" 23 - or: "evervision,ev-ft5726" 24 - or: "focaltech,ft6236" 25 - 26 - - reg: I2C slave address of the chip (0x38) 27 - - interrupts: interrupt specification for the touchdetect 28 - interrupt 29 - 30 - Optional properties: 31 - - reset-gpios: GPIO specification for the RESET input 32 - - wake-gpios: GPIO specification for the WAKE input 33 - - vcc-supply: Regulator that supplies the touchscreen 34 - 35 - - pinctrl-names: should be "default" 36 - - pinctrl-0: a phandle pointing to the pin settings for the 37 - control gpios 38 - 39 - - wakeup-source: If present the device will act as wakeup-source 40 - 41 - - threshold: allows setting the "click"-threshold in the range 42 - from 0 to 80. 43 - 44 - - gain: allows setting the sensitivity in the range from 0 to 45 - 31. Note that lower values indicate higher 46 - sensitivity. 47 - 48 - - offset: allows setting the edge compensation in the range from 49 - 0 to 31. 50 - 51 - - offset-x: Same as offset, but applies only to the horizontal position. 52 - Range from 0 to 80, only supported by evervision,ev-ft5726 53 - devices. 54 - 55 - - offset-y: Same as offset, but applies only to the vertical position. 56 - Range from 0 to 80, only supported by evervision,ev-ft5726 57 - devices. 58 - 59 - - touchscreen-size-x : See touchscreen.txt 60 - - touchscreen-size-y : See touchscreen.txt 61 - - touchscreen-fuzz-x : See touchscreen.txt 62 - - touchscreen-fuzz-y : See touchscreen.txt 63 - - touchscreen-inverted-x : See touchscreen.txt 64 - - touchscreen-inverted-y : See touchscreen.txt 65 - - touchscreen-swapped-x-y : See touchscreen.txt 66 - 67 - Example: 68 - polytouch: edt-ft5x06@38 { 69 - compatible = "edt,edt-ft5406", "edt,edt-ft5x06"; 70 - reg = <0x38>; 71 - pinctrl-names = "default"; 72 - pinctrl-0 = <&edt_ft5x06_pins>; 73 - interrupt-parent = <&gpio2>; 74 - interrupts = <5 IRQ_TYPE_EDGE_FALLING>; 75 - reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; 76 - wake-gpios = <&gpio4 9 GPIO_ACTIVE_HIGH>; 77 - };
+125
Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/input/touchscreen/edt-ft5x06.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: FocalTech EDT-FT5x06 Polytouch Bindings 8 + 9 + description: | 10 + There are 5 variants of the chip for various touch panel sizes 11 + FT5206GE1 2.8" .. 3.8" 12 + FT5306DE4 4.3" .. 7" 13 + FT5406EE8 7" .. 8.9" 14 + FT5506EEG 7" .. 8.9" 15 + FT5726NEI 5.7” .. 11.6" 16 + 17 + maintainers: 18 + - Dmitry Torokhov <dmitry.torokhov@gmail.com> 19 + 20 + allOf: 21 + - $ref: touchscreen.yaml# 22 + - if: 23 + properties: 24 + compatible: 25 + contains: 26 + enum: 27 + - evervision,ev-ft5726 28 + 29 + then: 30 + properties: 31 + offset-x: true 32 + offset-y: true 33 + 34 + properties: 35 + compatible: 36 + enum: 37 + - edt,edt-ft5206 38 + - edt,edt-ft5306 39 + - edt,edt-ft5406 40 + - edt,edt-ft5506 41 + - evervision,ev-ft5726 42 + - focaltech,ft6236 43 + 44 + reg: 45 + const: 0x38 46 + 47 + interrupts: 48 + maxItems: 1 49 + 50 + reset-gpios: 51 + maxItems: 1 52 + 53 + wake-gpios: 54 + maxItems: 1 55 + 56 + wakeup-source: true 57 + 58 + vcc-supply: 59 + maxItems: 1 60 + 61 + gain: 62 + description: Allows setting the sensitivity in the range from 0 to 31. 63 + Note that lower values indicate higher sensitivity. 64 + allOf: 65 + - $ref: /schemas/types.yaml#/definitions/uint32 66 + - minimum: 0 67 + - maximum: 31 68 + 69 + offset: 70 + description: Allows setting the edge compensation in the range from 0 to 31. 71 + allOf: 72 + - $ref: /schemas/types.yaml#/definitions/uint32 73 + - minimum: 0 74 + - maximum: 31 75 + 76 + offset-x: 77 + description: Same as offset, but applies only to the horizontal position. 78 + Range from 0 to 80, only supported by evervision,ev-ft5726 devices. 79 + allOf: 80 + - $ref: /schemas/types.yaml#/definitions/uint32 81 + - minimum: 0 82 + - maximum: 80 83 + 84 + offset-y: 85 + description: Same as offset, but applies only to the vertical position. 86 + Range from 0 to 80, only supported by evervision,ev-ft5726 devices. 87 + allOf: 88 + - $ref: /schemas/types.yaml#/definitions/uint32 89 + - minimum: 0 90 + - maximum: 80 91 + 92 + touchscreen-size-x: true 93 + touchscreen-size-y: true 94 + touchscreen-fuzz-x: true 95 + touchscreen-fuzz-y: true 96 + touchscreen-inverted-x: true 97 + touchscreen-inverted-y: true 98 + touchscreen-swapped-x-y: true 99 + interrupt-controller: true 100 + 101 + additionalProperties: false 102 + 103 + required: 104 + - compatible 105 + - reg 106 + - interrupts 107 + 108 + examples: 109 + - | 110 + #include <dt-bindings/gpio/gpio.h> 111 + #include <dt-bindings/interrupt-controller/arm-gic.h> 112 + i2c@00000000 { 113 + #address-cells = <1>; 114 + #size-cells = <0>; 115 + edt-ft5x06@38 { 116 + compatible = "edt,edt-ft5406"; 117 + reg = <0x38>; 118 + interrupt-parent = <&gpio2>; 119 + interrupts = <5 IRQ_TYPE_EDGE_FALLING>; 120 + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; 121 + wake-gpios = <&gpio4 9 GPIO_ACTIVE_HIGH>; 122 + }; 123 + }; 124 + 125 + ...
+2
Documentation/devicetree/bindings/input/touchscreen/goodix.yaml
··· 21 21 - goodix,gt911 22 22 - goodix,gt9110 23 23 - goodix,gt912 24 + - goodix,gt9147 25 + - goodix,gt917s 24 26 - goodix,gt927 25 27 - goodix,gt9271 26 28 - goodix,gt928
+11
drivers/input/serio/i8042-x86ia64io.h
··· 530 530 DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo LaVie Z"), 531 531 }, 532 532 }, 533 + { 534 + /* 535 + * Acer Aspire 5738z 536 + * Touchpad stops working in mux mode when dis- + re-enabled 537 + * with the touchpad enable/disable toggle hotkey 538 + */ 539 + .matches = { 540 + DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 541 + DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5738"), 542 + }, 543 + }, 533 544 { } 534 545 }; 535 546
+1
drivers/input/touchscreen/elants_i2c.c
··· 1309 1309 input_set_abs_params(ts->input, ABS_MT_PRESSURE, 0, 255, 0, 0); 1310 1310 input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->x_res); 1311 1311 input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->y_res); 1312 + input_abs_set_res(ts->input, ABS_MT_TOUCH_MAJOR, 1); 1312 1313 1313 1314 error = input_register_device(ts->input); 1314 1315 if (error) {
+498 -118
drivers/input/touchscreen/goodix.c
··· 29 29 #include <linux/of.h> 30 30 #include <asm/unaligned.h> 31 31 32 + #define GOODIX_GPIO_INT_NAME "irq" 33 + #define GOODIX_GPIO_RST_NAME "reset" 34 + 35 + #define GOODIX_MAX_HEIGHT 4096 36 + #define GOODIX_MAX_WIDTH 4096 37 + #define GOODIX_INT_TRIGGER 1 38 + #define GOODIX_CONTACT_SIZE 8 39 + #define GOODIX_MAX_CONTACT_SIZE 9 40 + #define GOODIX_MAX_CONTACTS 10 41 + #define GOODIX_MAX_KEYS 7 42 + 43 + #define GOODIX_CONFIG_MIN_LENGTH 186 44 + #define GOODIX_CONFIG_911_LENGTH 186 45 + #define GOODIX_CONFIG_967_LENGTH 228 46 + #define GOODIX_CONFIG_GT9X_LENGTH 240 47 + #define GOODIX_CONFIG_MAX_LENGTH 240 48 + 49 + /* Register defines */ 50 + #define GOODIX_REG_COMMAND 0x8040 51 + #define GOODIX_CMD_SCREEN_OFF 0x05 52 + 53 + #define GOODIX_READ_COOR_ADDR 0x814E 54 + #define GOODIX_GT1X_REG_CONFIG_DATA 0x8050 55 + #define GOODIX_GT9X_REG_CONFIG_DATA 0x8047 56 + #define GOODIX_REG_ID 0x8140 57 + 58 + #define GOODIX_BUFFER_STATUS_READY BIT(7) 59 + #define GOODIX_HAVE_KEY BIT(4) 60 + #define GOODIX_BUFFER_STATUS_TIMEOUT 20 61 + 62 + #define RESOLUTION_LOC 1 63 + #define MAX_CONTACTS_LOC 5 64 + #define TRIGGER_LOC 6 65 + 66 + /* Our special handling for GPIO accesses through ACPI is x86 specific */ 67 + #if defined CONFIG_X86 && defined CONFIG_ACPI 68 + #define ACPI_GPIO_SUPPORT 69 + #endif 70 + 32 71 struct goodix_ts_data; 72 + 73 + enum goodix_irq_pin_access_method { 74 + IRQ_PIN_ACCESS_NONE, 75 + IRQ_PIN_ACCESS_GPIO, 76 + IRQ_PIN_ACCESS_ACPI_GPIO, 77 + IRQ_PIN_ACCESS_ACPI_METHOD, 78 + }; 33 79 34 80 struct goodix_chip_data { 35 81 u16 config_addr; 36 82 int config_len; 37 - int (*check_config)(struct goodix_ts_data *, const struct firmware *); 83 + int (*check_config)(struct goodix_ts_data *ts, const u8 *cfg, int len); 84 + void (*calc_config_checksum)(struct goodix_ts_data *ts); 38 85 }; 86 + 87 + struct goodix_chip_id { 88 + const char *id; 89 + const struct goodix_chip_data *data; 90 + }; 91 + 92 + #define GOODIX_ID_MAX_LEN 4 39 93 40 94 struct goodix_ts_data { 41 95 struct i2c_client *client; ··· 102 48 struct regulator *vddio; 103 49 struct gpio_desc *gpiod_int; 104 50 struct gpio_desc *gpiod_rst; 105 - u16 id; 51 + int gpio_count; 52 + int gpio_int_idx; 53 + char id[GOODIX_ID_MAX_LEN + 1]; 106 54 u16 version; 107 55 const char *cfg_name; 56 + bool reset_controller_at_probe; 57 + bool load_cfg_from_disk; 108 58 struct completion firmware_loading_complete; 109 59 unsigned long irq_flags; 60 + enum goodix_irq_pin_access_method irq_pin_access_method; 110 61 unsigned int contact_size; 62 + u8 config[GOODIX_CONFIG_MAX_LENGTH]; 63 + unsigned short keymap[GOODIX_MAX_KEYS]; 111 64 }; 112 65 113 - #define GOODIX_GPIO_INT_NAME "irq" 114 - #define GOODIX_GPIO_RST_NAME "reset" 115 - 116 - #define GOODIX_MAX_HEIGHT 4096 117 - #define GOODIX_MAX_WIDTH 4096 118 - #define GOODIX_INT_TRIGGER 1 119 - #define GOODIX_CONTACT_SIZE 8 120 - #define GOODIX_MAX_CONTACT_SIZE 9 121 - #define GOODIX_MAX_CONTACTS 10 122 - 123 - #define GOODIX_CONFIG_MAX_LENGTH 240 124 - #define GOODIX_CONFIG_911_LENGTH 186 125 - #define GOODIX_CONFIG_967_LENGTH 228 126 - 127 - /* Register defines */ 128 - #define GOODIX_REG_COMMAND 0x8040 129 - #define GOODIX_CMD_SCREEN_OFF 0x05 130 - 131 - #define GOODIX_READ_COOR_ADDR 0x814E 132 - #define GOODIX_GT1X_REG_CONFIG_DATA 0x8050 133 - #define GOODIX_GT9X_REG_CONFIG_DATA 0x8047 134 - #define GOODIX_REG_ID 0x8140 135 - 136 - #define GOODIX_BUFFER_STATUS_READY BIT(7) 137 - #define GOODIX_BUFFER_STATUS_TIMEOUT 20 138 - 139 - #define RESOLUTION_LOC 1 140 - #define MAX_CONTACTS_LOC 5 141 - #define TRIGGER_LOC 6 142 - 143 66 static int goodix_check_cfg_8(struct goodix_ts_data *ts, 144 - const struct firmware *cfg); 67 + const u8 *cfg, int len); 145 68 static int goodix_check_cfg_16(struct goodix_ts_data *ts, 146 - const struct firmware *cfg); 69 + const u8 *cfg, int len); 70 + static void goodix_calc_cfg_checksum_8(struct goodix_ts_data *ts); 71 + static void goodix_calc_cfg_checksum_16(struct goodix_ts_data *ts); 147 72 148 73 static const struct goodix_chip_data gt1x_chip_data = { 149 74 .config_addr = GOODIX_GT1X_REG_CONFIG_DATA, 150 - .config_len = GOODIX_CONFIG_MAX_LENGTH, 75 + .config_len = GOODIX_CONFIG_GT9X_LENGTH, 151 76 .check_config = goodix_check_cfg_16, 77 + .calc_config_checksum = goodix_calc_cfg_checksum_16, 152 78 }; 153 79 154 80 static const struct goodix_chip_data gt911_chip_data = { 155 81 .config_addr = GOODIX_GT9X_REG_CONFIG_DATA, 156 82 .config_len = GOODIX_CONFIG_911_LENGTH, 157 83 .check_config = goodix_check_cfg_8, 84 + .calc_config_checksum = goodix_calc_cfg_checksum_8, 158 85 }; 159 86 160 87 static const struct goodix_chip_data gt967_chip_data = { 161 88 .config_addr = GOODIX_GT9X_REG_CONFIG_DATA, 162 89 .config_len = GOODIX_CONFIG_967_LENGTH, 163 90 .check_config = goodix_check_cfg_8, 91 + .calc_config_checksum = goodix_calc_cfg_checksum_8, 164 92 }; 165 93 166 94 static const struct goodix_chip_data gt9x_chip_data = { 167 95 .config_addr = GOODIX_GT9X_REG_CONFIG_DATA, 168 - .config_len = GOODIX_CONFIG_MAX_LENGTH, 96 + .config_len = GOODIX_CONFIG_GT9X_LENGTH, 169 97 .check_config = goodix_check_cfg_8, 98 + .calc_config_checksum = goodix_calc_cfg_checksum_8, 99 + }; 100 + 101 + static const struct goodix_chip_id goodix_chip_ids[] = { 102 + { .id = "1151", .data = &gt1x_chip_data }, 103 + { .id = "5663", .data = &gt1x_chip_data }, 104 + { .id = "5688", .data = &gt1x_chip_data }, 105 + { .id = "917S", .data = &gt1x_chip_data }, 106 + 107 + { .id = "911", .data = &gt911_chip_data }, 108 + { .id = "9271", .data = &gt911_chip_data }, 109 + { .id = "9110", .data = &gt911_chip_data }, 110 + { .id = "927", .data = &gt911_chip_data }, 111 + { .id = "928", .data = &gt911_chip_data }, 112 + 113 + { .id = "912", .data = &gt967_chip_data }, 114 + { .id = "9147", .data = &gt967_chip_data }, 115 + { .id = "967", .data = &gt967_chip_data }, 116 + { } 170 117 }; 171 118 172 119 static const unsigned long goodix_irq_flags[] = { ··· 218 163 .matches = { 219 164 DMI_MATCH(DMI_PRODUCT_NAME, "Lenovo YB1-X9") 220 165 } 166 + }, 167 + #endif 168 + {} 169 + }; 170 + 171 + /* 172 + * Those tablets have their x coordinate inverted 173 + */ 174 + static const struct dmi_system_id inverted_x_screen[] = { 175 + #if defined(CONFIG_DMI) && defined(CONFIG_X86) 176 + { 177 + .ident = "Cube I15-TC", 178 + .matches = { 179 + DMI_MATCH(DMI_SYS_VENDOR, "Cube"), 180 + DMI_MATCH(DMI_PRODUCT_NAME, "I15-TC") 181 + }, 221 182 }, 222 183 #endif 223 184 {} ··· 306 235 return goodix_i2c_write(client, reg, &value, sizeof(value)); 307 236 } 308 237 309 - static const struct goodix_chip_data *goodix_get_chip_data(u16 id) 238 + static const struct goodix_chip_data *goodix_get_chip_data(const char *id) 310 239 { 311 - switch (id) { 312 - case 1151: 313 - case 5663: 314 - case 5688: 315 - return &gt1x_chip_data; 240 + unsigned int i; 316 241 317 - case 911: 318 - case 9271: 319 - case 9110: 320 - case 927: 321 - case 928: 322 - return &gt911_chip_data; 323 - 324 - case 912: 325 - case 967: 326 - return &gt967_chip_data; 327 - 328 - default: 329 - return &gt9x_chip_data; 242 + for (i = 0; goodix_chip_ids[i].id; i++) { 243 + if (!strcmp(goodix_chip_ids[i].id, id)) 244 + return goodix_chip_ids[i].data; 330 245 } 246 + 247 + return &gt9x_chip_data; 331 248 } 332 249 333 250 static int goodix_ts_read_input_report(struct goodix_ts_data *ts, u8 *data) ··· 323 264 unsigned long max_timeout; 324 265 int touch_num; 325 266 int error; 267 + u16 addr = GOODIX_READ_COOR_ADDR; 268 + /* 269 + * We are going to read 1-byte header, 270 + * ts->contact_size * max(1, touch_num) bytes of coordinates 271 + * and 1-byte footer which contains the touch-key code. 272 + */ 273 + const int header_contact_keycode_size = 1 + ts->contact_size + 1; 326 274 327 275 /* 328 276 * The 'buffer status' bit, which indicates that the data is valid, is ··· 338 272 */ 339 273 max_timeout = jiffies + msecs_to_jiffies(GOODIX_BUFFER_STATUS_TIMEOUT); 340 274 do { 341 - error = goodix_i2c_read(ts->client, GOODIX_READ_COOR_ADDR, 342 - data, ts->contact_size + 1); 275 + error = goodix_i2c_read(ts->client, addr, data, 276 + header_contact_keycode_size); 343 277 if (error) { 344 278 dev_err(&ts->client->dev, "I2C transfer error: %d\n", 345 279 error); ··· 352 286 return -EPROTO; 353 287 354 288 if (touch_num > 1) { 355 - data += 1 + ts->contact_size; 289 + addr += header_contact_keycode_size; 290 + data += header_contact_keycode_size; 356 291 error = goodix_i2c_read(ts->client, 357 - GOODIX_READ_COOR_ADDR + 358 - 1 + ts->contact_size, 359 - data, 292 + addr, data, 360 293 ts->contact_size * 361 294 (touch_num - 1)); 362 295 if (error) ··· 372 307 * The Goodix panel will send spurious interrupts after a 373 308 * 'finger up' event, which will always cause a timeout. 374 309 */ 375 - return 0; 310 + return -ENOMSG; 376 311 } 377 312 378 313 static void goodix_ts_report_touch_8b(struct goodix_ts_data *ts, u8 *coor_data) ··· 405 340 input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, input_w); 406 341 } 407 342 343 + static void goodix_ts_report_key(struct goodix_ts_data *ts, u8 *data) 344 + { 345 + int touch_num; 346 + u8 key_value; 347 + int i; 348 + 349 + if (data[0] & GOODIX_HAVE_KEY) { 350 + touch_num = data[0] & 0x0f; 351 + key_value = data[1 + ts->contact_size * touch_num]; 352 + for (i = 0; i < GOODIX_MAX_KEYS; i++) 353 + if (key_value & BIT(i)) 354 + input_report_key(ts->input_dev, 355 + ts->keymap[i], 1); 356 + } else { 357 + for (i = 0; i < GOODIX_MAX_KEYS; i++) 358 + input_report_key(ts->input_dev, ts->keymap[i], 0); 359 + } 360 + } 361 + 408 362 /** 409 363 * goodix_process_events - Process incoming events 410 364 * ··· 434 350 */ 435 351 static void goodix_process_events(struct goodix_ts_data *ts) 436 352 { 437 - u8 point_data[1 + GOODIX_MAX_CONTACT_SIZE * GOODIX_MAX_CONTACTS]; 353 + u8 point_data[2 + GOODIX_MAX_CONTACT_SIZE * GOODIX_MAX_CONTACTS]; 438 354 int touch_num; 439 355 int i; 440 356 ··· 442 358 if (touch_num < 0) 443 359 return; 444 360 445 - /* 446 - * Bit 4 of the first byte reports the status of the capacitive 447 - * Windows/Home button. 448 - */ 449 - input_report_key(ts->input_dev, KEY_LEFTMETA, point_data[0] & BIT(4)); 361 + goodix_ts_report_key(ts, point_data); 450 362 451 363 for (i = 0; i < touch_num; i++) 452 364 if (ts->contact_size == 9) ··· 486 406 ts->irq_flags, ts->client->name, ts); 487 407 } 488 408 489 - static int goodix_check_cfg_8(struct goodix_ts_data *ts, 490 - const struct firmware *cfg) 409 + static int goodix_check_cfg_8(struct goodix_ts_data *ts, const u8 *cfg, int len) 491 410 { 492 - int i, raw_cfg_len = cfg->size - 2; 411 + int i, raw_cfg_len = len - 2; 493 412 u8 check_sum = 0; 494 413 495 414 for (i = 0; i < raw_cfg_len; i++) 496 - check_sum += cfg->data[i]; 415 + check_sum += cfg[i]; 497 416 check_sum = (~check_sum) + 1; 498 - if (check_sum != cfg->data[raw_cfg_len]) { 417 + if (check_sum != cfg[raw_cfg_len]) { 499 418 dev_err(&ts->client->dev, 500 419 "The checksum of the config fw is not correct"); 501 420 return -EINVAL; 502 421 } 503 422 504 - if (cfg->data[raw_cfg_len + 1] != 1) { 423 + if (cfg[raw_cfg_len + 1] != 1) { 505 424 dev_err(&ts->client->dev, 506 425 "Config fw must have Config_Fresh register set"); 507 426 return -EINVAL; ··· 509 430 return 0; 510 431 } 511 432 512 - static int goodix_check_cfg_16(struct goodix_ts_data *ts, 513 - const struct firmware *cfg) 433 + static void goodix_calc_cfg_checksum_8(struct goodix_ts_data *ts) 514 434 { 515 - int i, raw_cfg_len = cfg->size - 3; 435 + int i, raw_cfg_len = ts->chip->config_len - 2; 436 + u8 check_sum = 0; 437 + 438 + for (i = 0; i < raw_cfg_len; i++) 439 + check_sum += ts->config[i]; 440 + check_sum = (~check_sum) + 1; 441 + 442 + ts->config[raw_cfg_len] = check_sum; 443 + ts->config[raw_cfg_len + 1] = 1; /* Set "config_fresh" bit */ 444 + } 445 + 446 + static int goodix_check_cfg_16(struct goodix_ts_data *ts, const u8 *cfg, 447 + int len) 448 + { 449 + int i, raw_cfg_len = len - 3; 516 450 u16 check_sum = 0; 517 451 518 452 for (i = 0; i < raw_cfg_len; i += 2) 519 - check_sum += get_unaligned_be16(&cfg->data[i]); 453 + check_sum += get_unaligned_be16(&cfg[i]); 520 454 check_sum = (~check_sum) + 1; 521 - if (check_sum != get_unaligned_be16(&cfg->data[raw_cfg_len])) { 455 + if (check_sum != get_unaligned_be16(&cfg[raw_cfg_len])) { 522 456 dev_err(&ts->client->dev, 523 457 "The checksum of the config fw is not correct"); 524 458 return -EINVAL; 525 459 } 526 460 527 - if (cfg->data[raw_cfg_len + 2] != 1) { 461 + if (cfg[raw_cfg_len + 2] != 1) { 528 462 dev_err(&ts->client->dev, 529 463 "Config fw must have Config_Fresh register set"); 530 464 return -EINVAL; 531 465 } 532 466 533 467 return 0; 468 + } 469 + 470 + static void goodix_calc_cfg_checksum_16(struct goodix_ts_data *ts) 471 + { 472 + int i, raw_cfg_len = ts->chip->config_len - 3; 473 + u16 check_sum = 0; 474 + 475 + for (i = 0; i < raw_cfg_len; i += 2) 476 + check_sum += get_unaligned_be16(&ts->config[i]); 477 + check_sum = (~check_sum) + 1; 478 + 479 + put_unaligned_be16(check_sum, &ts->config[raw_cfg_len]); 480 + ts->config[raw_cfg_len + 2] = 1; /* Set "config_fresh" bit */ 534 481 } 535 482 536 483 /** ··· 565 460 * @ts: goodix_ts_data pointer 566 461 * @cfg: firmware config data 567 462 */ 568 - static int goodix_check_cfg(struct goodix_ts_data *ts, 569 - const struct firmware *cfg) 463 + static int goodix_check_cfg(struct goodix_ts_data *ts, const u8 *cfg, int len) 570 464 { 571 - if (cfg->size > GOODIX_CONFIG_MAX_LENGTH) { 465 + if (len < GOODIX_CONFIG_MIN_LENGTH || 466 + len > GOODIX_CONFIG_MAX_LENGTH) { 572 467 dev_err(&ts->client->dev, 573 468 "The length of the config fw is not correct"); 574 469 return -EINVAL; 575 470 } 576 471 577 - return ts->chip->check_config(ts, cfg); 472 + return ts->chip->check_config(ts, cfg, len); 578 473 } 579 474 580 475 /** ··· 583 478 * @ts: goodix_ts_data pointer 584 479 * @cfg: config firmware to write to device 585 480 */ 586 - static int goodix_send_cfg(struct goodix_ts_data *ts, 587 - const struct firmware *cfg) 481 + static int goodix_send_cfg(struct goodix_ts_data *ts, const u8 *cfg, int len) 588 482 { 589 483 int error; 590 484 591 - error = goodix_check_cfg(ts, cfg); 485 + error = goodix_check_cfg(ts, cfg, len); 592 486 if (error) 593 487 return error; 594 488 595 - error = goodix_i2c_write(ts->client, ts->chip->config_addr, cfg->data, 596 - cfg->size); 489 + error = goodix_i2c_write(ts->client, ts->chip->config_addr, cfg, len); 597 490 if (error) { 598 491 dev_err(&ts->client->dev, "Failed to write config data: %d", 599 492 error); ··· 605 502 return 0; 606 503 } 607 504 505 + #ifdef ACPI_GPIO_SUPPORT 506 + static int goodix_pin_acpi_direction_input(struct goodix_ts_data *ts) 507 + { 508 + acpi_handle handle = ACPI_HANDLE(&ts->client->dev); 509 + acpi_status status; 510 + 511 + status = acpi_evaluate_object(handle, "INTI", NULL, NULL); 512 + return ACPI_SUCCESS(status) ? 0 : -EIO; 513 + } 514 + 515 + static int goodix_pin_acpi_output_method(struct goodix_ts_data *ts, int value) 516 + { 517 + acpi_handle handle = ACPI_HANDLE(&ts->client->dev); 518 + acpi_status status; 519 + 520 + status = acpi_execute_simple_method(handle, "INTO", value); 521 + return ACPI_SUCCESS(status) ? 0 : -EIO; 522 + } 523 + #else 524 + static int goodix_pin_acpi_direction_input(struct goodix_ts_data *ts) 525 + { 526 + dev_err(&ts->client->dev, 527 + "%s called on device without ACPI support\n", __func__); 528 + return -EINVAL; 529 + } 530 + 531 + static int goodix_pin_acpi_output_method(struct goodix_ts_data *ts, int value) 532 + { 533 + dev_err(&ts->client->dev, 534 + "%s called on device without ACPI support\n", __func__); 535 + return -EINVAL; 536 + } 537 + #endif 538 + 539 + static int goodix_irq_direction_output(struct goodix_ts_data *ts, int value) 540 + { 541 + switch (ts->irq_pin_access_method) { 542 + case IRQ_PIN_ACCESS_NONE: 543 + dev_err(&ts->client->dev, 544 + "%s called without an irq_pin_access_method set\n", 545 + __func__); 546 + return -EINVAL; 547 + case IRQ_PIN_ACCESS_GPIO: 548 + return gpiod_direction_output(ts->gpiod_int, value); 549 + case IRQ_PIN_ACCESS_ACPI_GPIO: 550 + /* 551 + * The IRQ pin triggers on a falling edge, so its gets marked 552 + * as active-low, use output_raw to avoid the value inversion. 553 + */ 554 + return gpiod_direction_output_raw(ts->gpiod_int, value); 555 + case IRQ_PIN_ACCESS_ACPI_METHOD: 556 + return goodix_pin_acpi_output_method(ts, value); 557 + } 558 + 559 + return -EINVAL; /* Never reached */ 560 + } 561 + 562 + static int goodix_irq_direction_input(struct goodix_ts_data *ts) 563 + { 564 + switch (ts->irq_pin_access_method) { 565 + case IRQ_PIN_ACCESS_NONE: 566 + dev_err(&ts->client->dev, 567 + "%s called without an irq_pin_access_method set\n", 568 + __func__); 569 + return -EINVAL; 570 + case IRQ_PIN_ACCESS_GPIO: 571 + return gpiod_direction_input(ts->gpiod_int); 572 + case IRQ_PIN_ACCESS_ACPI_GPIO: 573 + return gpiod_direction_input(ts->gpiod_int); 574 + case IRQ_PIN_ACCESS_ACPI_METHOD: 575 + return goodix_pin_acpi_direction_input(ts); 576 + } 577 + 578 + return -EINVAL; /* Never reached */ 579 + } 580 + 608 581 static int goodix_int_sync(struct goodix_ts_data *ts) 609 582 { 610 583 int error; 611 584 612 - error = gpiod_direction_output(ts->gpiod_int, 0); 585 + error = goodix_irq_direction_output(ts, 0); 613 586 if (error) 614 587 return error; 615 588 616 589 msleep(50); /* T5: 50ms */ 617 590 618 - error = gpiod_direction_input(ts->gpiod_int); 591 + error = goodix_irq_direction_input(ts); 619 592 if (error) 620 593 return error; 621 594 ··· 715 536 msleep(20); /* T2: > 10ms */ 716 537 717 538 /* HIGH: 0x28/0x29, LOW: 0xBA/0xBB */ 718 - error = gpiod_direction_output(ts->gpiod_int, ts->client->addr == 0x14); 539 + error = goodix_irq_direction_output(ts, ts->client->addr == 0x14); 719 540 if (error) 720 541 return error; 721 542 ··· 739 560 return 0; 740 561 } 741 562 563 + #ifdef ACPI_GPIO_SUPPORT 564 + #include <asm/cpu_device_id.h> 565 + #include <asm/intel-family.h> 566 + 567 + static const struct x86_cpu_id baytrail_cpu_ids[] = { 568 + { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT, X86_FEATURE_ANY, }, 569 + {} 570 + }; 571 + 572 + static inline bool is_byt(void) 573 + { 574 + const struct x86_cpu_id *id = x86_match_cpu(baytrail_cpu_ids); 575 + 576 + return !!id; 577 + } 578 + 579 + static const struct acpi_gpio_params first_gpio = { 0, 0, false }; 580 + static const struct acpi_gpio_params second_gpio = { 1, 0, false }; 581 + 582 + static const struct acpi_gpio_mapping acpi_goodix_int_first_gpios[] = { 583 + { GOODIX_GPIO_INT_NAME "-gpios", &first_gpio, 1 }, 584 + { GOODIX_GPIO_RST_NAME "-gpios", &second_gpio, 1 }, 585 + { }, 586 + }; 587 + 588 + static const struct acpi_gpio_mapping acpi_goodix_int_last_gpios[] = { 589 + { GOODIX_GPIO_RST_NAME "-gpios", &first_gpio, 1 }, 590 + { GOODIX_GPIO_INT_NAME "-gpios", &second_gpio, 1 }, 591 + { }, 592 + }; 593 + 594 + static const struct acpi_gpio_mapping acpi_goodix_reset_only_gpios[] = { 595 + { GOODIX_GPIO_RST_NAME "-gpios", &first_gpio, 1 }, 596 + { }, 597 + }; 598 + 599 + static int goodix_resource(struct acpi_resource *ares, void *data) 600 + { 601 + struct goodix_ts_data *ts = data; 602 + struct device *dev = &ts->client->dev; 603 + struct acpi_resource_gpio *gpio; 604 + 605 + switch (ares->type) { 606 + case ACPI_RESOURCE_TYPE_GPIO: 607 + gpio = &ares->data.gpio; 608 + if (gpio->connection_type == ACPI_RESOURCE_GPIO_TYPE_INT) { 609 + if (ts->gpio_int_idx == -1) { 610 + ts->gpio_int_idx = ts->gpio_count; 611 + } else { 612 + dev_err(dev, "More then one GpioInt resource, ignoring ACPI GPIO resources\n"); 613 + ts->gpio_int_idx = -2; 614 + } 615 + } 616 + ts->gpio_count++; 617 + break; 618 + default: 619 + break; 620 + } 621 + 622 + return 0; 623 + } 624 + 625 + /* 626 + * This function gets called in case we fail to get the irq GPIO directly 627 + * because the ACPI tables lack GPIO-name to APCI _CRS index mappings 628 + * (no _DSD UUID daffd814-6eba-4d8c-8a91-bc9bbf4aa301 data). 629 + * In that case we add our own mapping and then goodix_get_gpio_config() 630 + * retries to get the GPIOs based on the added mapping. 631 + */ 632 + static int goodix_add_acpi_gpio_mappings(struct goodix_ts_data *ts) 633 + { 634 + const struct acpi_gpio_mapping *gpio_mapping = NULL; 635 + struct device *dev = &ts->client->dev; 636 + LIST_HEAD(resources); 637 + int ret; 638 + 639 + ts->gpio_count = 0; 640 + ts->gpio_int_idx = -1; 641 + ret = acpi_dev_get_resources(ACPI_COMPANION(dev), &resources, 642 + goodix_resource, ts); 643 + if (ret < 0) { 644 + dev_err(dev, "Error getting ACPI resources: %d\n", ret); 645 + return ret; 646 + } 647 + 648 + acpi_dev_free_resource_list(&resources); 649 + 650 + if (ts->gpio_count == 2 && ts->gpio_int_idx == 0) { 651 + ts->irq_pin_access_method = IRQ_PIN_ACCESS_ACPI_GPIO; 652 + gpio_mapping = acpi_goodix_int_first_gpios; 653 + } else if (ts->gpio_count == 2 && ts->gpio_int_idx == 1) { 654 + ts->irq_pin_access_method = IRQ_PIN_ACCESS_ACPI_GPIO; 655 + gpio_mapping = acpi_goodix_int_last_gpios; 656 + } else if (ts->gpio_count == 1 && ts->gpio_int_idx == -1 && 657 + acpi_has_method(ACPI_HANDLE(dev), "INTI") && 658 + acpi_has_method(ACPI_HANDLE(dev), "INTO")) { 659 + dev_info(dev, "Using ACPI INTI and INTO methods for IRQ pin access\n"); 660 + ts->irq_pin_access_method = IRQ_PIN_ACCESS_ACPI_METHOD; 661 + gpio_mapping = acpi_goodix_reset_only_gpios; 662 + } else if (is_byt() && ts->gpio_count == 2 && ts->gpio_int_idx == -1) { 663 + dev_info(dev, "No ACPI GpioInt resource, assuming that the GPIO order is reset, int\n"); 664 + ts->irq_pin_access_method = IRQ_PIN_ACCESS_ACPI_GPIO; 665 + gpio_mapping = acpi_goodix_int_last_gpios; 666 + } else { 667 + dev_warn(dev, "Unexpected ACPI resources: gpio_count %d, gpio_int_idx %d\n", 668 + ts->gpio_count, ts->gpio_int_idx); 669 + return -EINVAL; 670 + } 671 + 672 + return devm_acpi_dev_add_driver_gpios(dev, gpio_mapping); 673 + } 674 + #else 675 + static int goodix_add_acpi_gpio_mappings(struct goodix_ts_data *ts) 676 + { 677 + return -EINVAL; 678 + } 679 + #endif /* CONFIG_X86 && CONFIG_ACPI */ 680 + 742 681 /** 743 682 * goodix_get_gpio_config - Get GPIO config from ACPI/DT 744 683 * ··· 867 570 int error; 868 571 struct device *dev; 869 572 struct gpio_desc *gpiod; 573 + bool added_acpi_mappings = false; 870 574 871 575 if (!ts->client) 872 576 return -EINVAL; ··· 891 593 return error; 892 594 } 893 595 596 + retry_get_irq_gpio: 894 597 /* Get the interrupt GPIO pin number */ 895 598 gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_INT_NAME, GPIOD_IN); 896 599 if (IS_ERR(gpiod)) { ··· 900 601 dev_dbg(dev, "Failed to get %s GPIO: %d\n", 901 602 GOODIX_GPIO_INT_NAME, error); 902 603 return error; 604 + } 605 + if (!gpiod && has_acpi_companion(dev) && !added_acpi_mappings) { 606 + added_acpi_mappings = true; 607 + if (goodix_add_acpi_gpio_mappings(ts) == 0) 608 + goto retry_get_irq_gpio; 903 609 } 904 610 905 611 ts->gpiod_int = gpiod; ··· 921 617 922 618 ts->gpiod_rst = gpiod; 923 619 620 + switch (ts->irq_pin_access_method) { 621 + case IRQ_PIN_ACCESS_ACPI_GPIO: 622 + /* 623 + * We end up here if goodix_add_acpi_gpio_mappings() has 624 + * called devm_acpi_dev_add_driver_gpios() because the ACPI 625 + * tables did not contain name to index mappings. 626 + * Check that we successfully got both GPIOs after we've 627 + * added our own acpi_gpio_mapping and if we did not get both 628 + * GPIOs reset irq_pin_access_method to IRQ_PIN_ACCESS_NONE. 629 + */ 630 + if (!ts->gpiod_int || !ts->gpiod_rst) 631 + ts->irq_pin_access_method = IRQ_PIN_ACCESS_NONE; 632 + break; 633 + case IRQ_PIN_ACCESS_ACPI_METHOD: 634 + if (!ts->gpiod_rst) 635 + ts->irq_pin_access_method = IRQ_PIN_ACCESS_NONE; 636 + break; 637 + default: 638 + if (ts->gpiod_int && ts->gpiod_rst) { 639 + ts->reset_controller_at_probe = true; 640 + ts->load_cfg_from_disk = true; 641 + ts->irq_pin_access_method = IRQ_PIN_ACCESS_GPIO; 642 + } 643 + } 644 + 924 645 return 0; 925 646 } 926 647 ··· 958 629 */ 959 630 static void goodix_read_config(struct goodix_ts_data *ts) 960 631 { 961 - u8 config[GOODIX_CONFIG_MAX_LENGTH]; 962 632 int x_max, y_max; 963 633 int error; 964 634 965 635 error = goodix_i2c_read(ts->client, ts->chip->config_addr, 966 - config, ts->chip->config_len); 636 + ts->config, ts->chip->config_len); 967 637 if (error) { 968 638 dev_warn(&ts->client->dev, "Error reading config: %d\n", 969 639 error); ··· 971 643 return; 972 644 } 973 645 974 - ts->int_trigger_type = config[TRIGGER_LOC] & 0x03; 975 - ts->max_touch_num = config[MAX_CONTACTS_LOC] & 0x0f; 646 + ts->int_trigger_type = ts->config[TRIGGER_LOC] & 0x03; 647 + ts->max_touch_num = ts->config[MAX_CONTACTS_LOC] & 0x0f; 976 648 977 - x_max = get_unaligned_le16(&config[RESOLUTION_LOC]); 978 - y_max = get_unaligned_le16(&config[RESOLUTION_LOC + 2]); 649 + x_max = get_unaligned_le16(&ts->config[RESOLUTION_LOC]); 650 + y_max = get_unaligned_le16(&ts->config[RESOLUTION_LOC + 2]); 979 651 if (x_max && y_max) { 980 652 input_abs_set_max(ts->input_dev, ABS_MT_POSITION_X, x_max - 1); 981 653 input_abs_set_max(ts->input_dev, ABS_MT_POSITION_Y, y_max - 1); 982 654 } 655 + 656 + ts->chip->calc_config_checksum(ts); 983 657 } 984 658 985 659 /** ··· 993 663 { 994 664 int error; 995 665 u8 buf[6]; 996 - char id_str[5]; 666 + char id_str[GOODIX_ID_MAX_LEN + 1]; 997 667 998 668 error = goodix_i2c_read(ts->client, GOODIX_REG_ID, buf, sizeof(buf)); 999 669 if (error) { ··· 1001 671 return error; 1002 672 } 1003 673 1004 - memcpy(id_str, buf, 4); 1005 - id_str[4] = 0; 1006 - if (kstrtou16(id_str, 10, &ts->id)) 1007 - ts->id = 0x1001; 674 + memcpy(id_str, buf, GOODIX_ID_MAX_LEN); 675 + id_str[GOODIX_ID_MAX_LEN] = 0; 676 + strscpy(ts->id, id_str, GOODIX_ID_MAX_LEN + 1); 1008 677 1009 678 ts->version = get_unaligned_le16(&buf[4]); 1010 679 1011 - dev_info(&ts->client->dev, "ID %d, version: %04x\n", ts->id, 680 + dev_info(&ts->client->dev, "ID %s, version: %04x\n", ts->id, 1012 681 ts->version); 1013 682 1014 683 return 0; ··· 1051 722 static int goodix_configure_dev(struct goodix_ts_data *ts) 1052 723 { 1053 724 int error; 725 + int i; 1054 726 1055 727 ts->int_trigger_type = GOODIX_INT_TRIGGER; 1056 728 ts->max_touch_num = GOODIX_MAX_CONTACTS; ··· 1066 736 ts->input_dev->phys = "input/ts"; 1067 737 ts->input_dev->id.bustype = BUS_I2C; 1068 738 ts->input_dev->id.vendor = 0x0416; 1069 - ts->input_dev->id.product = ts->id; 739 + if (kstrtou16(ts->id, 10, &ts->input_dev->id.product)) 740 + ts->input_dev->id.product = 0x1001; 1070 741 ts->input_dev->id.version = ts->version; 1071 742 743 + ts->input_dev->keycode = ts->keymap; 744 + ts->input_dev->keycodesize = sizeof(ts->keymap[0]); 745 + ts->input_dev->keycodemax = GOODIX_MAX_KEYS; 746 + 1072 747 /* Capacitive Windows/Home button on some devices */ 1073 - input_set_capability(ts->input_dev, EV_KEY, KEY_LEFTMETA); 748 + for (i = 0; i < GOODIX_MAX_KEYS; ++i) { 749 + if (i == 0) 750 + ts->keymap[i] = KEY_LEFTMETA; 751 + else 752 + ts->keymap[i] = KEY_F1 + (i - 1); 753 + 754 + input_set_capability(ts->input_dev, EV_KEY, ts->keymap[i]); 755 + } 1074 756 1075 757 input_set_capability(ts->input_dev, EV_ABS, ABS_MT_POSITION_X); 1076 758 input_set_capability(ts->input_dev, EV_ABS, ABS_MT_POSITION_Y); ··· 1120 778 1121 779 dev_dbg(&ts->client->dev, 1122 780 "Non-standard 9-bytes report format quirk\n"); 781 + } 782 + 783 + if (dmi_check_system(inverted_x_screen)) { 784 + ts->prop.invert_x = true; 785 + dev_dbg(&ts->client->dev, 786 + "Applying 'inverted x screen' quirk\n"); 1123 787 } 1124 788 1125 789 error = input_mt_init_slots(ts->input_dev, ts->max_touch_num, ··· 1168 820 1169 821 if (cfg) { 1170 822 /* send device configuration to the firmware */ 1171 - error = goodix_send_cfg(ts, cfg); 823 + error = goodix_send_cfg(ts, cfg->data, cfg->size); 1172 824 if (error) 1173 825 goto err_release_cfg; 1174 826 } ··· 1237 889 if (error) 1238 890 return error; 1239 891 1240 - if (ts->gpiod_int && ts->gpiod_rst) { 892 + reset: 893 + if (ts->reset_controller_at_probe) { 1241 894 /* reset the controller */ 1242 895 error = goodix_reset(ts); 1243 896 if (error) { ··· 1249 900 1250 901 error = goodix_i2c_test(client); 1251 902 if (error) { 903 + if (!ts->reset_controller_at_probe && 904 + ts->irq_pin_access_method != IRQ_PIN_ACCESS_NONE) { 905 + /* Retry after a controller reset */ 906 + ts->reset_controller_at_probe = true; 907 + goto reset; 908 + } 1252 909 dev_err(&client->dev, "I2C communication failure: %d\n", error); 1253 910 return error; 1254 911 } ··· 1267 912 1268 913 ts->chip = goodix_get_chip_data(ts->id); 1269 914 1270 - if (ts->gpiod_int && ts->gpiod_rst) { 915 + if (ts->load_cfg_from_disk) { 1271 916 /* update device config */ 1272 917 ts->cfg_name = devm_kasprintf(&client->dev, GFP_KERNEL, 1273 - "goodix_%d_cfg.bin", ts->id); 918 + "goodix_%s_cfg.bin", ts->id); 1274 919 if (!ts->cfg_name) 1275 920 return -ENOMEM; 1276 921 ··· 1298 943 { 1299 944 struct goodix_ts_data *ts = i2c_get_clientdata(client); 1300 945 1301 - if (ts->gpiod_int && ts->gpiod_rst) 946 + if (ts->load_cfg_from_disk) 1302 947 wait_for_completion(&ts->firmware_loading_complete); 1303 948 1304 949 return 0; ··· 1310 955 struct goodix_ts_data *ts = i2c_get_clientdata(client); 1311 956 int error; 1312 957 958 + if (ts->load_cfg_from_disk) 959 + wait_for_completion(&ts->firmware_loading_complete); 960 + 1313 961 /* We need gpio pins to suspend/resume */ 1314 - if (!ts->gpiod_int || !ts->gpiod_rst) { 962 + if (ts->irq_pin_access_method == IRQ_PIN_ACCESS_NONE) { 1315 963 disable_irq(client->irq); 1316 964 return 0; 1317 965 } 1318 - 1319 - wait_for_completion(&ts->firmware_loading_complete); 1320 966 1321 967 /* Free IRQ as IRQ pin is used as output in the suspend sequence */ 1322 968 goodix_free_irq(ts); 1323 969 1324 970 /* Output LOW on the INT pin for 5 ms */ 1325 - error = gpiod_direction_output(ts->gpiod_int, 0); 971 + error = goodix_irq_direction_output(ts, 0); 1326 972 if (error) { 1327 973 goodix_request_irq(ts); 1328 974 return error; ··· 1335 979 GOODIX_CMD_SCREEN_OFF); 1336 980 if (error) { 1337 981 dev_err(&ts->client->dev, "Screen off command failed\n"); 1338 - gpiod_direction_input(ts->gpiod_int); 982 + goodix_irq_direction_input(ts); 1339 983 goodix_request_irq(ts); 1340 984 return -EAGAIN; 1341 985 } ··· 1353 997 { 1354 998 struct i2c_client *client = to_i2c_client(dev); 1355 999 struct goodix_ts_data *ts = i2c_get_clientdata(client); 1000 + u8 config_ver; 1356 1001 int error; 1357 1002 1358 - if (!ts->gpiod_int || !ts->gpiod_rst) { 1003 + if (ts->irq_pin_access_method == IRQ_PIN_ACCESS_NONE) { 1359 1004 enable_irq(client->irq); 1360 1005 return 0; 1361 1006 } ··· 1365 1008 * Exit sleep mode by outputting HIGH level to INT pin 1366 1009 * for 2ms~5ms. 1367 1010 */ 1368 - error = gpiod_direction_output(ts->gpiod_int, 1); 1011 + error = goodix_irq_direction_output(ts, 1); 1369 1012 if (error) 1370 1013 return error; 1371 1014 ··· 1374 1017 error = goodix_int_sync(ts); 1375 1018 if (error) 1376 1019 return error; 1020 + 1021 + error = goodix_i2c_read(ts->client, ts->chip->config_addr, 1022 + &config_ver, 1); 1023 + if (error) 1024 + dev_warn(dev, "Error reading config version: %d, resetting controller\n", 1025 + error); 1026 + else if (config_ver != ts->config[0]) 1027 + dev_info(dev, "Config version mismatch %d != %d, resetting controller\n", 1028 + config_ver, ts->config[0]); 1029 + 1030 + if (error != 0 || config_ver != ts->config[0]) { 1031 + error = goodix_reset(ts); 1032 + if (error) { 1033 + dev_err(dev, "Controller reset failed.\n"); 1034 + return error; 1035 + } 1036 + 1037 + error = goodix_send_cfg(ts, ts->config, ts->chip->config_len); 1038 + if (error) 1039 + return error; 1040 + } 1377 1041 1378 1042 error = goodix_request_irq(ts); 1379 1043 if (error) ··· 1428 1050 { .compatible = "goodix,gt911" }, 1429 1051 { .compatible = "goodix,gt9110" }, 1430 1052 { .compatible = "goodix,gt912" }, 1053 + { .compatible = "goodix,gt9147" }, 1054 + { .compatible = "goodix,gt917s" }, 1431 1055 { .compatible = "goodix,gt927" }, 1432 1056 { .compatible = "goodix,gt9271" }, 1433 1057 { .compatible = "goodix,gt928" },
+17 -18
drivers/input/touchscreen/of_touchscreen.c
··· 66 66 { 67 67 struct device *dev = input->dev.parent; 68 68 struct input_absinfo *absinfo; 69 - unsigned int axis; 69 + unsigned int axis, axis_x, axis_y; 70 70 unsigned int minimum, maximum, fuzz; 71 71 bool data_present; 72 72 ··· 74 74 if (!input->absinfo) 75 75 return; 76 76 77 - axis = multitouch ? ABS_MT_POSITION_X : ABS_X; 77 + axis_x = multitouch ? ABS_MT_POSITION_X : ABS_X; 78 + axis_y = multitouch ? ABS_MT_POSITION_Y : ABS_Y; 79 + 78 80 data_present = touchscreen_get_prop_u32(dev, "touchscreen-min-x", 79 - input_abs_get_min(input, axis), 81 + input_abs_get_min(input, axis_x), 80 82 &minimum) | 81 83 touchscreen_get_prop_u32(dev, "touchscreen-size-x", 82 84 input_abs_get_max(input, 83 - axis) + 1, 85 + axis_x) + 1, 84 86 &maximum) | 85 87 touchscreen_get_prop_u32(dev, "touchscreen-fuzz-x", 86 - input_abs_get_fuzz(input, axis), 88 + input_abs_get_fuzz(input, axis_x), 87 89 &fuzz); 88 90 if (data_present) 89 - touchscreen_set_params(input, axis, minimum, maximum - 1, fuzz); 91 + touchscreen_set_params(input, axis_x, minimum, maximum - 1, fuzz); 90 92 91 - axis = multitouch ? ABS_MT_POSITION_Y : ABS_Y; 92 93 data_present = touchscreen_get_prop_u32(dev, "touchscreen-min-y", 93 - input_abs_get_min(input, axis), 94 + input_abs_get_min(input, axis_y), 94 95 &minimum) | 95 96 touchscreen_get_prop_u32(dev, "touchscreen-size-y", 96 97 input_abs_get_max(input, 97 - axis) + 1, 98 + axis_y) + 1, 98 99 &maximum) | 99 100 touchscreen_get_prop_u32(dev, "touchscreen-fuzz-y", 100 - input_abs_get_fuzz(input, axis), 101 + input_abs_get_fuzz(input, axis_y), 101 102 &fuzz); 102 103 if (data_present) 103 - touchscreen_set_params(input, axis, minimum, maximum - 1, fuzz); 104 + touchscreen_set_params(input, axis_y, minimum, maximum - 1, fuzz); 104 105 105 106 axis = multitouch ? ABS_MT_PRESSURE : ABS_PRESSURE; 106 107 data_present = touchscreen_get_prop_u32(dev, ··· 118 117 if (!prop) 119 118 return; 120 119 121 - axis = multitouch ? ABS_MT_POSITION_X : ABS_X; 122 - 123 - prop->max_x = input_abs_get_max(input, axis); 124 - prop->max_y = input_abs_get_max(input, axis + 1); 120 + prop->max_x = input_abs_get_max(input, axis_x); 121 + prop->max_y = input_abs_get_max(input, axis_y); 125 122 126 123 prop->invert_x = 127 124 device_property_read_bool(dev, "touchscreen-inverted-x"); 128 125 if (prop->invert_x) { 129 - absinfo = &input->absinfo[axis]; 126 + absinfo = &input->absinfo[axis_x]; 130 127 absinfo->maximum -= absinfo->minimum; 131 128 absinfo->minimum = 0; 132 129 } ··· 132 133 prop->invert_y = 133 134 device_property_read_bool(dev, "touchscreen-inverted-y"); 134 135 if (prop->invert_y) { 135 - absinfo = &input->absinfo[axis + 1]; 136 + absinfo = &input->absinfo[axis_y]; 136 137 absinfo->maximum -= absinfo->minimum; 137 138 absinfo->minimum = 0; 138 139 } ··· 140 141 prop->swap_x_y = 141 142 device_property_read_bool(dev, "touchscreen-swapped-x-y"); 142 143 if (prop->swap_x_y) 143 - swap(input->absinfo[axis], input->absinfo[axis + 1]); 144 + swap(input->absinfo[axis_x], input->absinfo[axis_y]); 144 145 } 145 146 EXPORT_SYMBOL(touchscreen_parse_properties); 146 147
+1 -1
include/uapi/linux/input-event-codes.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 1 + /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ 2 2 /* 3 3 * Input event codes 4 4 *