Lines Matching +full:client +full:- +full:id

1 // SPDX-License-Identifier: GPL-2.0-only
10 * 2010 - 2012 Goodix Technology.
57 const char *id; member
97 { .id = "1151", .data = &gt1x_chip_data },
98 { .id = "1158", .data = &gt1x_chip_data },
99 { .id = "5663", .data = &gt1x_chip_data },
100 { .id = "5688", .data = &gt1x_chip_data },
101 { .id = "917S", .data = &gt1x_chip_data },
102 { .id = "9286", .data = &gt1x_chip_data },
104 { .id = "911", .data = &gt911_chip_data },
105 { .id = "9271", .data = &gt911_chip_data },
106 { .id = "9110", .data = &gt911_chip_data },
107 { .id = "9111", .data = &gt911_chip_data },
108 { .id = "927", .data = &gt911_chip_data },
109 { .id = "928", .data = &gt911_chip_data },
111 { .id = "912", .data = &gt967_chip_data },
112 { .id = "9147", .data = &gt967_chip_data },
113 { .id = "967", .data = &gt967_chip_data },
128 /* YB1-X91L/F and YB1-X90L/F */
130 DMI_MATCH(DMI_PRODUCT_NAME, "Lenovo YB1-X9")
143 .ident = "Cube I15-TC",
146 DMI_MATCH(DMI_PRODUCT_NAME, "I15-TC")
154 * goodix_i2c_read - read data from a register of the i2c slave device.
156 * @client: i2c device.
161 int goodix_i2c_read(struct i2c_client *client, u16 reg, u8 *buf, int len) in goodix_i2c_read() argument
168 msgs[0].addr = client->addr; in goodix_i2c_read()
173 msgs[1].addr = client->addr; in goodix_i2c_read()
177 ret = i2c_transfer(client->adapter, msgs, 2); in goodix_i2c_read()
179 ret = (ret == ARRAY_SIZE(msgs) ? 0 : -EIO); in goodix_i2c_read()
182 dev_err(&client->dev, "Error reading %d bytes from 0x%04x: %d\n", in goodix_i2c_read()
188 * goodix_i2c_write - write data to a register of the i2c slave device.
190 * @client: i2c device.
195 int goodix_i2c_write(struct i2c_client *client, u16 reg, const u8 *buf, int len) in goodix_i2c_write() argument
203 return -ENOMEM; in goodix_i2c_write()
210 msg.addr = client->addr; in goodix_i2c_write()
214 ret = i2c_transfer(client->adapter, &msg, 1); in goodix_i2c_write()
216 ret = (ret == 1 ? 0 : -EIO); in goodix_i2c_write()
221 dev_err(&client->dev, "Error writing %d bytes to 0x%04x: %d\n", in goodix_i2c_write()
226 int goodix_i2c_write_u8(struct i2c_client *client, u16 reg, u8 value) in goodix_i2c_write_u8() argument
228 return goodix_i2c_write(client, reg, &value, sizeof(value)); in goodix_i2c_write_u8()
231 static const struct goodix_chip_data *goodix_get_chip_data(const char *id) in goodix_get_chip_data() argument
235 for (i = 0; goodix_chip_ids[i].id; i++) { in goodix_get_chip_data()
236 if (!strcmp(goodix_chip_ids[i].id, id)) in goodix_get_chip_data()
250 * We are going to read 1-byte header, in goodix_ts_read_input_report()
251 * ts->contact_size * max(1, touch_num) bytes of coordinates in goodix_ts_read_input_report()
252 * and 1-byte footer which contains the touch-key code. in goodix_ts_read_input_report()
254 const int header_contact_keycode_size = 1 + ts->contact_size + 1; in goodix_ts_read_input_report()
263 error = goodix_i2c_read(ts->client, addr, data, in goodix_ts_read_input_report()
270 if (touch_num > ts->max_touch_num) in goodix_ts_read_input_report()
271 return -EPROTO; in goodix_ts_read_input_report()
276 error = goodix_i2c_read(ts->client, in goodix_ts_read_input_report()
278 ts->contact_size * in goodix_ts_read_input_report()
279 (touch_num - 1)); in goodix_ts_read_input_report()
287 if (data[0] == 0 && ts->firmware_name) { in goodix_ts_read_input_report()
292 usleep_range(1000, 2000); /* Poll every 1 - 2 ms */ in goodix_ts_read_input_report()
299 return -ENOMSG; in goodix_ts_read_input_report()
304 struct device *dev = &ts->client->dev; in goodix_create_pen_input()
309 return -ENOMEM; in goodix_create_pen_input()
311 input_copy_abs(input, ABS_X, ts->input_dev, ABS_MT_POSITION_X); in goodix_create_pen_input()
312 input_copy_abs(input, ABS_Y, ts->input_dev, ABS_MT_POSITION_Y); in goodix_create_pen_input()
326 __set_bit(INPUT_PROP_DIRECT, input->propbit); in goodix_create_pen_input()
328 input->name = "Goodix Active Pen"; in goodix_create_pen_input()
329 input->phys = "input/pen"; in goodix_create_pen_input()
330 input->id.bustype = BUS_I2C; in goodix_create_pen_input()
331 input->id.vendor = 0x0416; in goodix_create_pen_input()
332 if (kstrtou16(ts->id, 10, &input->id.product)) in goodix_create_pen_input()
333 input->id.product = 0x1001; in goodix_create_pen_input()
334 input->id.version = ts->version; in goodix_create_pen_input()
336 ts->input_pen = input; in goodix_create_pen_input()
345 if (!ts->pen_input_registered) { in goodix_ts_report_pen_down()
346 error = input_register_device(ts->input_pen); in goodix_ts_report_pen_down()
347 ts->pen_input_registered = (error == 0) ? 1 : error; in goodix_ts_report_pen_down()
350 if (ts->pen_input_registered < 0) in goodix_ts_report_pen_down()
353 if (ts->contact_size == 9) { in goodix_ts_report_pen_down()
363 touchscreen_report_pos(ts->input_pen, &ts->prop, input_x, input_y, false); in goodix_ts_report_pen_down()
364 input_report_abs(ts->input_pen, ABS_PRESSURE, input_w); in goodix_ts_report_pen_down()
366 input_report_key(ts->input_pen, BTN_TOUCH, 1); in goodix_ts_report_pen_down()
367 input_report_key(ts->input_pen, BTN_TOOL_PEN, 1); in goodix_ts_report_pen_down()
370 key_value = data[1 + ts->contact_size]; in goodix_ts_report_pen_down()
371 input_report_key(ts->input_pen, BTN_STYLUS, key_value & 0x10); in goodix_ts_report_pen_down()
372 input_report_key(ts->input_pen, BTN_STYLUS2, key_value & 0x20); in goodix_ts_report_pen_down()
374 input_report_key(ts->input_pen, BTN_STYLUS, 0); in goodix_ts_report_pen_down()
375 input_report_key(ts->input_pen, BTN_STYLUS2, 0); in goodix_ts_report_pen_down()
378 input_sync(ts->input_pen); in goodix_ts_report_pen_down()
383 if (!ts->input_pen) in goodix_ts_report_pen_up()
386 input_report_key(ts->input_pen, BTN_TOUCH, 0); in goodix_ts_report_pen_up()
387 input_report_key(ts->input_pen, BTN_TOOL_PEN, 0); in goodix_ts_report_pen_up()
388 input_report_key(ts->input_pen, BTN_STYLUS, 0); in goodix_ts_report_pen_up()
389 input_report_key(ts->input_pen, BTN_STYLUS2, 0); in goodix_ts_report_pen_up()
391 input_sync(ts->input_pen); in goodix_ts_report_pen_up()
396 int id = coor_data[0] & 0x0F; in goodix_ts_report_touch_8b() local
401 input_mt_slot(ts->input_dev, id); in goodix_ts_report_touch_8b()
402 input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true); in goodix_ts_report_touch_8b()
403 touchscreen_report_pos(ts->input_dev, &ts->prop, in goodix_ts_report_touch_8b()
405 input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, input_w); in goodix_ts_report_touch_8b()
406 input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, input_w); in goodix_ts_report_touch_8b()
411 int id = coor_data[1] & 0x0F; in goodix_ts_report_touch_9b() local
416 input_mt_slot(ts->input_dev, id); in goodix_ts_report_touch_9b()
417 input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true); in goodix_ts_report_touch_9b()
418 touchscreen_report_pos(ts->input_dev, &ts->prop, in goodix_ts_report_touch_9b()
420 input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, input_w); in goodix_ts_report_touch_9b()
421 input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, input_w); in goodix_ts_report_touch_9b()
429 input_report_key(ts->input_dev, ts->keymap[i], 0); in goodix_ts_release_keys()
440 key_value = data[1 + ts->contact_size * touch_num]; in goodix_ts_report_key()
443 input_report_key(ts->input_dev, in goodix_ts_report_key()
444 ts->keymap[i], 1); in goodix_ts_report_key()
451 * goodix_process_events - Process incoming events
480 if (ts->contact_size == 9) in goodix_process_events()
482 &point_data[1 + ts->contact_size * i]); in goodix_process_events()
485 &point_data[1 + ts->contact_size * i]); in goodix_process_events()
488 input_mt_sync_frame(ts->input_dev); in goodix_process_events()
489 input_sync(ts->input_dev); in goodix_process_events()
493 * goodix_ts_irq_handler - The IRQ handler
503 goodix_i2c_write_u8(ts->client, GOODIX_READ_COOR_ADDR, 0); in goodix_ts_irq_handler()
510 devm_free_irq(&ts->client->dev, ts->client->irq, ts); in goodix_free_irq()
515 return devm_request_threaded_irq(&ts->client->dev, ts->client->irq, in goodix_request_irq()
517 ts->irq_flags, ts->client->name, ts); in goodix_request_irq()
522 int i, raw_cfg_len = len - 2; in goodix_check_cfg_8()
529 dev_err(&ts->client->dev, in goodix_check_cfg_8()
531 return -EINVAL; in goodix_check_cfg_8()
535 dev_err(&ts->client->dev, in goodix_check_cfg_8()
537 return -EINVAL; in goodix_check_cfg_8()
545 int i, raw_cfg_len = ts->chip->config_len - 2; in goodix_calc_cfg_checksum_8()
549 check_sum += ts->config[i]; in goodix_calc_cfg_checksum_8()
552 ts->config[raw_cfg_len] = check_sum; in goodix_calc_cfg_checksum_8()
553 ts->config[raw_cfg_len + 1] = 1; /* Set "config_fresh" bit */ in goodix_calc_cfg_checksum_8()
559 int i, raw_cfg_len = len - 3; in goodix_check_cfg_16()
566 dev_err(&ts->client->dev, in goodix_check_cfg_16()
568 return -EINVAL; in goodix_check_cfg_16()
572 dev_err(&ts->client->dev, in goodix_check_cfg_16()
574 return -EINVAL; in goodix_check_cfg_16()
582 int i, raw_cfg_len = ts->chip->config_len - 3; in goodix_calc_cfg_checksum_16()
586 check_sum += get_unaligned_be16(&ts->config[i]); in goodix_calc_cfg_checksum_16()
589 put_unaligned_be16(check_sum, &ts->config[raw_cfg_len]); in goodix_calc_cfg_checksum_16()
590 ts->config[raw_cfg_len + 2] = 1; /* Set "config_fresh" bit */ in goodix_calc_cfg_checksum_16()
594 * goodix_check_cfg - Checks if config fw is valid
604 dev_err(&ts->client->dev, in goodix_check_cfg()
606 return -EINVAL; in goodix_check_cfg()
609 return ts->chip->check_config(ts, cfg, len); in goodix_check_cfg()
613 * goodix_send_cfg - Write fw config to device
627 error = goodix_i2c_write(ts->client, ts->chip->config_addr, cfg, len); in goodix_send_cfg()
631 dev_dbg(&ts->client->dev, "Config sent successfully."); in goodix_send_cfg()
642 acpi_handle handle = ACPI_HANDLE(&ts->client->dev); in goodix_pin_acpi_direction_input()
646 return ACPI_SUCCESS(status) ? 0 : -EIO; in goodix_pin_acpi_direction_input()
651 acpi_handle handle = ACPI_HANDLE(&ts->client->dev); in goodix_pin_acpi_output_method()
655 return ACPI_SUCCESS(status) ? 0 : -EIO; in goodix_pin_acpi_output_method()
660 dev_err(&ts->client->dev, in goodix_pin_acpi_direction_input()
662 return -EINVAL; in goodix_pin_acpi_direction_input()
667 dev_err(&ts->client->dev, in goodix_pin_acpi_output_method()
669 return -EINVAL; in goodix_pin_acpi_output_method()
675 switch (ts->irq_pin_access_method) { in goodix_irq_direction_output()
677 dev_err(&ts->client->dev, in goodix_irq_direction_output()
680 return -EINVAL; in goodix_irq_direction_output()
682 return gpiod_direction_output(ts->gpiod_int, value); in goodix_irq_direction_output()
686 * as active-low, use output_raw to avoid the value inversion. in goodix_irq_direction_output()
688 return gpiod_direction_output_raw(ts->gpiod_int, value); in goodix_irq_direction_output()
693 return -EINVAL; /* Never reached */ in goodix_irq_direction_output()
698 switch (ts->irq_pin_access_method) { in goodix_irq_direction_input()
700 dev_err(&ts->client->dev, in goodix_irq_direction_input()
703 return -EINVAL; in goodix_irq_direction_input()
705 return gpiod_direction_input(ts->gpiod_int); in goodix_irq_direction_input()
707 return gpiod_direction_input(ts->gpiod_int); in goodix_irq_direction_input()
712 return -EINVAL; /* Never reached */ in goodix_irq_direction_input()
732 dev_err(&ts->client->dev, "Controller irq sync failed.\n"); in goodix_int_sync()
737 * goodix_reset_no_int_sync - Reset device, leaving interrupt line in output mode
746 error = gpiod_direction_output(ts->gpiod_rst, 0); in goodix_reset_no_int_sync()
753 error = goodix_irq_direction_output(ts, ts->client->addr == 0x14); in goodix_reset_no_int_sync()
759 error = gpiod_direction_output(ts->gpiod_rst, 1); in goodix_reset_no_int_sync()
766 * Put the reset pin back in to input / high-impedance mode to save in goodix_reset_no_int_sync()
768 * don't have a pull-up, so there the reset pin must stay active-high. in goodix_reset_no_int_sync()
770 if (ts->irq_pin_access_method == IRQ_PIN_ACCESS_GPIO) { in goodix_reset_no_int_sync()
771 error = gpiod_direction_input(ts->gpiod_rst); in goodix_reset_no_int_sync()
779 dev_err(&ts->client->dev, "Controller reset failed.\n"); in goodix_reset_no_int_sync()
784 * goodix_reset - Reset device during power on
804 { GOODIX_GPIO_INT_NAME "-gpios", &first_gpio, 1 },
805 { GOODIX_GPIO_RST_NAME "-gpios", &second_gpio, 1 },
810 { GOODIX_GPIO_RST_NAME "-gpios", &first_gpio, 1 },
811 { GOODIX_GPIO_INT_NAME "-gpios", &second_gpio, 1 },
816 { GOODIX_GPIO_RST_NAME "-gpios", &first_gpio, 1 },
823 struct device *dev = &ts->client->dev; in goodix_resource()
827 if (ts->gpio_int_idx == -1) { in goodix_resource()
828 ts->gpio_int_idx = ts->gpio_count; in goodix_resource()
831 ts->gpio_int_idx = -2; in goodix_resource()
833 ts->gpio_count++; in goodix_resource()
835 ts->gpio_count++; in goodix_resource()
842 * because the ACPI tables lack GPIO-name to APCI _CRS index mappings
843 * (no _DSD UUID daffd814-6eba-4d8c-8a91-bc9bbf4aa301 data).
850 struct device *dev = &ts->client->dev; in goodix_add_acpi_gpio_mappings()
854 ts->gpio_count = 0; in goodix_add_acpi_gpio_mappings()
855 ts->gpio_int_idx = -1; in goodix_add_acpi_gpio_mappings()
868 * resource copied from a previous BYT based generation). i2c-core-acpi in goodix_add_acpi_gpio_mappings()
869 * will use the non-working Interrupt resource, fix this up. in goodix_add_acpi_gpio_mappings()
871 if (soc_intel_is_cht() && ts->gpio_count == 2 && ts->gpio_int_idx != -1) { in goodix_add_acpi_gpio_mappings()
873 if (irq > 0 && irq != ts->client->irq) { in goodix_add_acpi_gpio_mappings()
874 dev_warn(dev, "Overriding IRQ %d -> %d\n", ts->client->irq, irq); in goodix_add_acpi_gpio_mappings()
875 ts->client->irq = irq; in goodix_add_acpi_gpio_mappings()
879 if (ts->gpio_count == 2 && ts->gpio_int_idx == 0) { in goodix_add_acpi_gpio_mappings()
880 ts->irq_pin_access_method = IRQ_PIN_ACCESS_ACPI_GPIO; in goodix_add_acpi_gpio_mappings()
882 } else if (ts->gpio_count == 2 && ts->gpio_int_idx == 1) { in goodix_add_acpi_gpio_mappings()
883 ts->irq_pin_access_method = IRQ_PIN_ACCESS_ACPI_GPIO; in goodix_add_acpi_gpio_mappings()
885 } else if (ts->gpio_count == 1 && ts->gpio_int_idx == -1 && in goodix_add_acpi_gpio_mappings()
889 ts->irq_pin_access_method = IRQ_PIN_ACCESS_ACPI_METHOD; in goodix_add_acpi_gpio_mappings()
891 } else if (soc_intel_is_byt() && ts->gpio_count == 2 && ts->gpio_int_idx == -1) { in goodix_add_acpi_gpio_mappings()
893 ts->irq_pin_access_method = IRQ_PIN_ACCESS_ACPI_GPIO; in goodix_add_acpi_gpio_mappings()
897 ts->gpio_count, ts->gpio_int_idx); in goodix_add_acpi_gpio_mappings()
903 return -EINVAL; in goodix_add_acpi_gpio_mappings()
907 * Normally we put the reset pin in input / high-impedance mode to save in goodix_add_acpi_gpio_mappings()
908 * power. But some x86/ACPI boards don't have a pull-up, so for the ACPI in goodix_add_acpi_gpio_mappings()
910 * at all on x86/ACPI boards, except when needed for error-recover. in goodix_add_acpi_gpio_mappings()
912 ts->gpiod_rst_flags = GPIOD_ASIS; in goodix_add_acpi_gpio_mappings()
919 return -EINVAL; in goodix_add_acpi_gpio_mappings()
924 * goodix_get_gpio_config - Get GPIO config from ACPI/DT
935 if (!ts->client) in goodix_get_gpio_config()
936 return -EINVAL; in goodix_get_gpio_config()
937 dev = &ts->client->dev; in goodix_get_gpio_config()
941 * high-impedance when not resetting the controller to save power. in goodix_get_gpio_config()
943 ts->gpiod_rst_flags = GPIOD_IN; in goodix_get_gpio_config()
945 ts->avdd28 = devm_regulator_get(dev, "AVDD28"); in goodix_get_gpio_config()
946 if (IS_ERR(ts->avdd28)) { in goodix_get_gpio_config()
947 error = PTR_ERR(ts->avdd28); in goodix_get_gpio_config()
948 if (error != -EPROBE_DEFER) in goodix_get_gpio_config()
954 ts->vddio = devm_regulator_get(dev, "VDDIO"); in goodix_get_gpio_config()
955 if (IS_ERR(ts->vddio)) { in goodix_get_gpio_config()
956 error = PTR_ERR(ts->vddio); in goodix_get_gpio_config()
957 if (error != -EPROBE_DEFER) in goodix_get_gpio_config()
968 if (error != -EPROBE_DEFER) in goodix_get_gpio_config()
979 ts->gpiod_int = gpiod; in goodix_get_gpio_config()
982 gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_RST_NAME, ts->gpiod_rst_flags); in goodix_get_gpio_config()
985 if (error != -EPROBE_DEFER) in goodix_get_gpio_config()
991 ts->gpiod_rst = gpiod; in goodix_get_gpio_config()
993 switch (ts->irq_pin_access_method) { in goodix_get_gpio_config()
1003 if (!ts->gpiod_int || !ts->gpiod_rst) in goodix_get_gpio_config()
1004 ts->irq_pin_access_method = IRQ_PIN_ACCESS_NONE; in goodix_get_gpio_config()
1007 if (!ts->gpiod_rst) in goodix_get_gpio_config()
1008 ts->irq_pin_access_method = IRQ_PIN_ACCESS_NONE; in goodix_get_gpio_config()
1011 if (ts->gpiod_int && ts->gpiod_rst) { in goodix_get_gpio_config()
1012 ts->reset_controller_at_probe = true; in goodix_get_gpio_config()
1013 ts->load_cfg_from_disk = true; in goodix_get_gpio_config()
1014 ts->irq_pin_access_method = IRQ_PIN_ACCESS_GPIO; in goodix_get_gpio_config()
1022 * goodix_read_config - Read the embedded configuration of the panel
1035 * (controllers without flash) ts->config already has the config in goodix_read_config()
1038 if (!ts->firmware_name) { in goodix_read_config()
1039 error = goodix_i2c_read(ts->client, ts->chip->config_addr, in goodix_read_config()
1040 ts->config, ts->chip->config_len); in goodix_read_config()
1042 ts->int_trigger_type = GOODIX_INT_TRIGGER; in goodix_read_config()
1043 ts->max_touch_num = GOODIX_MAX_CONTACTS; in goodix_read_config()
1048 ts->int_trigger_type = ts->config[TRIGGER_LOC] & 0x03; in goodix_read_config()
1049 ts->max_touch_num = ts->config[MAX_CONTACTS_LOC] & 0x0f; in goodix_read_config()
1051 x_max = get_unaligned_le16(&ts->config[RESOLUTION_LOC]); in goodix_read_config()
1052 y_max = get_unaligned_le16(&ts->config[RESOLUTION_LOC + 2]); in goodix_read_config()
1054 input_abs_set_max(ts->input_dev, ABS_MT_POSITION_X, x_max - 1); in goodix_read_config()
1055 input_abs_set_max(ts->input_dev, ABS_MT_POSITION_Y, y_max - 1); in goodix_read_config()
1058 ts->chip->calc_config_checksum(ts); in goodix_read_config()
1062 * goodix_read_version - Read goodix touchscreen version
1072 error = goodix_i2c_read(ts->client, GOODIX_REG_ID, buf, sizeof(buf)); in goodix_read_version()
1078 strscpy(ts->id, id_str, GOODIX_ID_MAX_LEN + 1); in goodix_read_version()
1080 ts->version = get_unaligned_le16(&buf[4]); in goodix_read_version()
1082 dev_info(&ts->client->dev, "ID %s, version: %04x\n", ts->id, in goodix_read_version()
1083 ts->version); in goodix_read_version()
1089 * goodix_i2c_test - I2C test function to check if the device answers.
1091 * @client: the i2c client
1093 static int goodix_i2c_test(struct i2c_client *client) in goodix_i2c_test() argument
1100 error = goodix_i2c_read(client, GOODIX_REG_ID, &test, 1); in goodix_i2c_test()
1111 * goodix_configure_dev - Finish device initialization
1125 ts->int_trigger_type = GOODIX_INT_TRIGGER; in goodix_configure_dev()
1126 ts->max_touch_num = GOODIX_MAX_CONTACTS; in goodix_configure_dev()
1128 ts->input_dev = devm_input_allocate_device(&ts->client->dev); in goodix_configure_dev()
1129 if (!ts->input_dev) { in goodix_configure_dev()
1130 dev_err(&ts->client->dev, "Failed to allocate input device."); in goodix_configure_dev()
1131 return -ENOMEM; in goodix_configure_dev()
1134 ts->input_dev->name = "Goodix Capacitive TouchScreen"; in goodix_configure_dev()
1135 ts->input_dev->phys = "input/ts"; in goodix_configure_dev()
1136 ts->input_dev->id.bustype = BUS_I2C; in goodix_configure_dev()
1137 ts->input_dev->id.vendor = 0x0416; in goodix_configure_dev()
1138 if (kstrtou16(ts->id, 10, &ts->input_dev->id.product)) in goodix_configure_dev()
1139 ts->input_dev->id.product = 0x1001; in goodix_configure_dev()
1140 ts->input_dev->id.version = ts->version; in goodix_configure_dev()
1142 ts->input_dev->keycode = ts->keymap; in goodix_configure_dev()
1143 ts->input_dev->keycodesize = sizeof(ts->keymap[0]); in goodix_configure_dev()
1144 ts->input_dev->keycodemax = GOODIX_MAX_KEYS; in goodix_configure_dev()
1149 ts->keymap[i] = KEY_LEFTMETA; in goodix_configure_dev()
1151 ts->keymap[i] = KEY_F1 + (i - 1); in goodix_configure_dev()
1153 input_set_capability(ts->input_dev, EV_KEY, ts->keymap[i]); in goodix_configure_dev()
1156 input_set_capability(ts->input_dev, EV_ABS, ABS_MT_POSITION_X); in goodix_configure_dev()
1157 input_set_capability(ts->input_dev, EV_ABS, ABS_MT_POSITION_Y); in goodix_configure_dev()
1158 input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0); in goodix_configure_dev()
1159 input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); in goodix_configure_dev()
1166 touchscreen_parse_properties(ts->input_dev, true, &ts->prop); in goodix_configure_dev()
1168 if (!ts->prop.max_x || !ts->prop.max_y || !ts->max_touch_num) { in goodix_configure_dev()
1169 if (!ts->reset_controller_at_probe && in goodix_configure_dev()
1170 ts->irq_pin_access_method != IRQ_PIN_ACCESS_NONE) { in goodix_configure_dev()
1171 dev_info(&ts->client->dev, "Config not set, resetting controller\n"); in goodix_configure_dev()
1173 ts->reset_controller_at_probe = true; in goodix_configure_dev()
1179 dev_err(&ts->client->dev, in goodix_configure_dev()
1181 ts->prop.max_x, ts->prop.max_y, ts->max_touch_num); in goodix_configure_dev()
1182 ts->prop.max_x = GOODIX_MAX_WIDTH - 1; in goodix_configure_dev()
1183 ts->prop.max_y = GOODIX_MAX_HEIGHT - 1; in goodix_configure_dev()
1184 ts->max_touch_num = GOODIX_MAX_CONTACTS; in goodix_configure_dev()
1185 input_abs_set_max(ts->input_dev, in goodix_configure_dev()
1186 ABS_MT_POSITION_X, ts->prop.max_x); in goodix_configure_dev()
1187 input_abs_set_max(ts->input_dev, in goodix_configure_dev()
1188 ABS_MT_POSITION_Y, ts->prop.max_y); in goodix_configure_dev()
1192 ts->contact_size = 9; in goodix_configure_dev()
1194 dev_dbg(&ts->client->dev, in goodix_configure_dev()
1195 "Non-standard 9-bytes report format quirk\n"); in goodix_configure_dev()
1199 ts->prop.invert_x = true; in goodix_configure_dev()
1200 dev_dbg(&ts->client->dev, in goodix_configure_dev()
1204 error = input_mt_init_slots(ts->input_dev, ts->max_touch_num, in goodix_configure_dev()
1207 dev_err(&ts->client->dev, in goodix_configure_dev()
1212 error = input_register_device(ts->input_dev); in goodix_configure_dev()
1214 dev_err(&ts->client->dev, in goodix_configure_dev()
1230 ts->irq_flags = goodix_irq_flags[ts->int_trigger_type] | IRQF_ONESHOT; in goodix_configure_dev()
1233 dev_err(&ts->client->dev, "request IRQ failed: %d\n", error); in goodix_configure_dev()
1241 * goodix_config_cb - Callback to finish device init
1254 if (ts->firmware_name) { in goodix_config_cb()
1258 error = goodix_check_cfg(ts, cfg->data, cfg->size); in goodix_config_cb()
1262 memcpy(ts->config, cfg->data, cfg->size); in goodix_config_cb()
1265 error = goodix_send_cfg(ts, cfg->data, cfg->size); in goodix_config_cb()
1274 complete_all(&ts->firmware_loading_complete); in goodix_config_cb()
1281 regulator_disable(ts->vddio); in goodix_disable_regulators()
1282 regulator_disable(ts->avdd28); in goodix_disable_regulators()
1285 static int goodix_ts_probe(struct i2c_client *client, in goodix_ts_probe() argument
1286 const struct i2c_device_id *id) in goodix_ts_probe() argument
1292 dev_dbg(&client->dev, "I2C Address: 0x%02x\n", client->addr); in goodix_ts_probe()
1294 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { in goodix_ts_probe()
1295 dev_err(&client->dev, "I2C check functionality failed.\n"); in goodix_ts_probe()
1296 return -ENXIO; in goodix_ts_probe()
1299 ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); in goodix_ts_probe()
1301 return -ENOMEM; in goodix_ts_probe()
1303 ts->client = client; in goodix_ts_probe()
1304 i2c_set_clientdata(client, ts); in goodix_ts_probe()
1305 init_completion(&ts->firmware_loading_complete); in goodix_ts_probe()
1306 ts->contact_size = GOODIX_CONTACT_SIZE; in goodix_ts_probe()
1313 error = regulator_enable(ts->avdd28); in goodix_ts_probe()
1315 dev_err(&client->dev, in goodix_ts_probe()
1321 error = regulator_enable(ts->vddio); in goodix_ts_probe()
1323 dev_err(&client->dev, in goodix_ts_probe()
1326 regulator_disable(ts->avdd28); in goodix_ts_probe()
1330 error = devm_add_action_or_reset(&client->dev, in goodix_ts_probe()
1336 if (ts->reset_controller_at_probe) { in goodix_ts_probe()
1343 error = goodix_i2c_test(client); in goodix_ts_probe()
1345 if (!ts->reset_controller_at_probe && in goodix_ts_probe()
1346 ts->irq_pin_access_method != IRQ_PIN_ACCESS_NONE) { in goodix_ts_probe()
1348 ts->reset_controller_at_probe = true; in goodix_ts_probe()
1351 dev_err(&client->dev, "I2C communication failure: %d\n", error); in goodix_ts_probe()
1363 ts->chip = goodix_get_chip_data(ts->id); in goodix_ts_probe()
1365 if (ts->load_cfg_from_disk) { in goodix_ts_probe()
1367 error = device_property_read_string(&client->dev, in goodix_ts_probe()
1368 "goodix,config-name", in goodix_ts_probe()
1371 snprintf(ts->cfg_name, sizeof(ts->cfg_name), in goodix_ts_probe()
1374 snprintf(ts->cfg_name, sizeof(ts->cfg_name), in goodix_ts_probe()
1375 "goodix_%s_cfg.bin", ts->id); in goodix_ts_probe()
1377 error = request_firmware_nowait(THIS_MODULE, true, ts->cfg_name, in goodix_ts_probe()
1378 &client->dev, GFP_KERNEL, ts, in goodix_ts_probe()
1381 dev_err(&client->dev, in goodix_ts_probe()
1397 static void goodix_ts_remove(struct i2c_client *client) in goodix_ts_remove() argument
1399 struct goodix_ts_data *ts = i2c_get_clientdata(client); in goodix_ts_remove()
1401 if (ts->load_cfg_from_disk) in goodix_ts_remove()
1402 wait_for_completion(&ts->firmware_loading_complete); in goodix_ts_remove()
1407 struct i2c_client *client = to_i2c_client(dev); in goodix_suspend() local
1408 struct goodix_ts_data *ts = i2c_get_clientdata(client); in goodix_suspend()
1411 if (ts->load_cfg_from_disk) in goodix_suspend()
1412 wait_for_completion(&ts->firmware_loading_complete); in goodix_suspend()
1415 if (ts->irq_pin_access_method == IRQ_PIN_ACCESS_NONE) { in goodix_suspend()
1416 disable_irq(client->irq); in goodix_suspend()
1435 error = goodix_i2c_write_u8(ts->client, GOODIX_REG_COMMAND, in goodix_suspend()
1440 return -EAGAIN; in goodix_suspend()
1444 * The datasheet specifies that the interval between sending screen-off in goodix_suspend()
1445 * command and wake-up should be longer than 58 ms. To avoid waking up in goodix_suspend()
1454 struct i2c_client *client = to_i2c_client(dev); in goodix_resume() local
1455 struct goodix_ts_data *ts = i2c_get_clientdata(client); in goodix_resume()
1459 if (ts->irq_pin_access_method == IRQ_PIN_ACCESS_NONE) { in goodix_resume()
1460 enable_irq(client->irq); in goodix_resume()
1478 error = goodix_i2c_read(ts->client, ts->chip->config_addr, in goodix_resume()
1480 if (!error && config_ver != ts->config[0]) in goodix_resume()
1482 config_ver, ts->config[0]); in goodix_resume()
1484 if (error != 0 || config_ver != ts->config[0]) { in goodix_resume()
1489 error = goodix_send_cfg(ts, ts->config, ts->chip->config_len); in goodix_resume()
1544 .name = "Goodix-TS",