Lines Matching +full:fw +full:- +full:gpios
1 // SPDX-License-Identifier: GPL-2.0-only
10 * 2010 - 2012 Goodix Technology.
131 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "YETI-11"),
138 DMI_MATCH(DMI_PRODUCT_NAME, "Lenovo YB1-X91"),
151 .ident = "Cube I15-TC",
154 DMI_MATCH(DMI_PRODUCT_NAME, "I15-TC")
162 * goodix_i2c_read - read data from a register of the i2c slave device.
176 msgs[0].addr = client->addr; in goodix_i2c_read()
181 msgs[1].addr = client->addr; in goodix_i2c_read()
185 ret = i2c_transfer(client->adapter, msgs, 2); in goodix_i2c_read()
187 ret = (ret == ARRAY_SIZE(msgs) ? 0 : -EIO); in goodix_i2c_read()
190 dev_err(&client->dev, "Error reading %d bytes from 0x%04x: %d\n", in goodix_i2c_read()
196 * goodix_i2c_write - write data to a register of the i2c slave device.
211 return -ENOMEM; in goodix_i2c_write()
218 msg.addr = client->addr; in goodix_i2c_write()
222 ret = i2c_transfer(client->adapter, &msg, 1); in goodix_i2c_write()
224 ret = (ret == 1 ? 0 : -EIO); in goodix_i2c_write()
229 dev_err(&client->dev, "Error writing %d bytes to 0x%04x: %d\n", in goodix_i2c_write()
258 * We are going to read 1-byte header, in goodix_ts_read_input_report()
259 * ts->contact_size * max(1, touch_num) bytes of coordinates in goodix_ts_read_input_report()
260 * and 1-byte footer which contains the touch-key code. in goodix_ts_read_input_report()
262 const int header_contact_keycode_size = 1 + ts->contact_size + 1; in goodix_ts_read_input_report()
271 error = goodix_i2c_read(ts->client, addr, data, in goodix_ts_read_input_report()
278 if (touch_num > ts->max_touch_num) in goodix_ts_read_input_report()
279 return -EPROTO; in goodix_ts_read_input_report()
284 error = goodix_i2c_read(ts->client, in goodix_ts_read_input_report()
286 ts->contact_size * in goodix_ts_read_input_report()
287 (touch_num - 1)); in goodix_ts_read_input_report()
295 if (data[0] == 0 && ts->firmware_name) { in goodix_ts_read_input_report()
300 usleep_range(1000, 2000); /* Poll every 1 - 2 ms */ in goodix_ts_read_input_report()
307 return -ENOMSG; in goodix_ts_read_input_report()
312 struct device *dev = &ts->client->dev; in goodix_create_pen_input()
317 return -ENOMEM; in goodix_create_pen_input()
319 input_copy_abs(input, ABS_X, ts->input_dev, ABS_MT_POSITION_X); in goodix_create_pen_input()
320 input_copy_abs(input, ABS_Y, ts->input_dev, ABS_MT_POSITION_Y); in goodix_create_pen_input()
334 __set_bit(INPUT_PROP_DIRECT, input->propbit); in goodix_create_pen_input()
336 input->name = "Goodix Active Pen"; in goodix_create_pen_input()
337 input->phys = "input/pen"; in goodix_create_pen_input()
338 input->id.bustype = BUS_I2C; in goodix_create_pen_input()
339 input->id.vendor = 0x0416; in goodix_create_pen_input()
340 if (kstrtou16(ts->id, 10, &input->id.product)) in goodix_create_pen_input()
341 input->id.product = 0x1001; in goodix_create_pen_input()
342 input->id.version = ts->version; in goodix_create_pen_input()
344 ts->input_pen = input; in goodix_create_pen_input()
353 if (!ts->pen_input_registered) { in goodix_ts_report_pen_down()
354 error = input_register_device(ts->input_pen); in goodix_ts_report_pen_down()
355 ts->pen_input_registered = (error == 0) ? 1 : error; in goodix_ts_report_pen_down()
358 if (ts->pen_input_registered < 0) in goodix_ts_report_pen_down()
361 if (ts->contact_size == 9) { in goodix_ts_report_pen_down()
371 touchscreen_report_pos(ts->input_pen, &ts->prop, input_x, input_y, false); in goodix_ts_report_pen_down()
372 input_report_abs(ts->input_pen, ABS_PRESSURE, input_w); in goodix_ts_report_pen_down()
374 input_report_key(ts->input_pen, BTN_TOUCH, 1); in goodix_ts_report_pen_down()
375 input_report_key(ts->input_pen, BTN_TOOL_PEN, 1); in goodix_ts_report_pen_down()
378 key_value = data[1 + ts->contact_size]; in goodix_ts_report_pen_down()
379 input_report_key(ts->input_pen, BTN_STYLUS, key_value & 0x10); in goodix_ts_report_pen_down()
380 input_report_key(ts->input_pen, BTN_STYLUS2, key_value & 0x20); in goodix_ts_report_pen_down()
382 input_report_key(ts->input_pen, BTN_STYLUS, 0); in goodix_ts_report_pen_down()
383 input_report_key(ts->input_pen, BTN_STYLUS2, 0); in goodix_ts_report_pen_down()
386 input_sync(ts->input_pen); in goodix_ts_report_pen_down()
391 if (!ts->input_pen) in goodix_ts_report_pen_up()
394 input_report_key(ts->input_pen, BTN_TOUCH, 0); in goodix_ts_report_pen_up()
395 input_report_key(ts->input_pen, BTN_TOOL_PEN, 0); in goodix_ts_report_pen_up()
396 input_report_key(ts->input_pen, BTN_STYLUS, 0); in goodix_ts_report_pen_up()
397 input_report_key(ts->input_pen, BTN_STYLUS2, 0); in goodix_ts_report_pen_up()
399 input_sync(ts->input_pen); in goodix_ts_report_pen_up()
409 input_mt_slot(ts->input_dev, id); in goodix_ts_report_touch_8b()
410 input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true); in goodix_ts_report_touch_8b()
411 touchscreen_report_pos(ts->input_dev, &ts->prop, in goodix_ts_report_touch_8b()
413 input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, input_w); in goodix_ts_report_touch_8b()
414 input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, input_w); in goodix_ts_report_touch_8b()
424 input_mt_slot(ts->input_dev, id); in goodix_ts_report_touch_9b()
425 input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true); in goodix_ts_report_touch_9b()
426 touchscreen_report_pos(ts->input_dev, &ts->prop, in goodix_ts_report_touch_9b()
428 input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, input_w); in goodix_ts_report_touch_9b()
429 input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, input_w); in goodix_ts_report_touch_9b()
437 input_report_key(ts->input_dev, ts->keymap[i], 0); in goodix_ts_release_keys()
448 key_value = data[1 + ts->contact_size * touch_num]; in goodix_ts_report_key()
451 input_report_key(ts->input_dev, in goodix_ts_report_key()
452 ts->keymap[i], 1); in goodix_ts_report_key()
459 * goodix_process_events - Process incoming events
488 if (ts->contact_size == 9) in goodix_process_events()
490 &point_data[1 + ts->contact_size * i]); in goodix_process_events()
493 &point_data[1 + ts->contact_size * i]); in goodix_process_events()
496 input_mt_sync_frame(ts->input_dev); in goodix_process_events()
497 input_sync(ts->input_dev); in goodix_process_events()
501 * goodix_ts_irq_handler - The IRQ handler
511 goodix_i2c_write_u8(ts->client, GOODIX_READ_COOR_ADDR, 0); in goodix_ts_irq_handler()
518 devm_free_irq(&ts->client->dev, ts->client->irq, ts); in goodix_free_irq()
523 return devm_request_threaded_irq(&ts->client->dev, ts->client->irq, in goodix_request_irq()
525 ts->irq_flags, ts->client->name, ts); in goodix_request_irq()
530 int i, raw_cfg_len = len - 2; in goodix_check_cfg_8()
537 dev_err(&ts->client->dev, in goodix_check_cfg_8()
538 "The checksum of the config fw is not correct"); in goodix_check_cfg_8()
539 return -EINVAL; in goodix_check_cfg_8()
543 dev_err(&ts->client->dev, in goodix_check_cfg_8()
544 "Config fw must have Config_Fresh register set"); in goodix_check_cfg_8()
545 return -EINVAL; in goodix_check_cfg_8()
553 int i, raw_cfg_len = ts->chip->config_len - 2; in goodix_calc_cfg_checksum_8()
557 check_sum += ts->config[i]; in goodix_calc_cfg_checksum_8()
560 ts->config[raw_cfg_len] = check_sum; in goodix_calc_cfg_checksum_8()
561 ts->config[raw_cfg_len + 1] = 1; /* Set "config_fresh" bit */ in goodix_calc_cfg_checksum_8()
567 int i, raw_cfg_len = len - 3; in goodix_check_cfg_16()
574 dev_err(&ts->client->dev, in goodix_check_cfg_16()
575 "The checksum of the config fw is not correct"); in goodix_check_cfg_16()
576 return -EINVAL; in goodix_check_cfg_16()
580 dev_err(&ts->client->dev, in goodix_check_cfg_16()
581 "Config fw must have Config_Fresh register set"); in goodix_check_cfg_16()
582 return -EINVAL; in goodix_check_cfg_16()
590 int i, raw_cfg_len = ts->chip->config_len - 3; in goodix_calc_cfg_checksum_16()
594 check_sum += get_unaligned_be16(&ts->config[i]); in goodix_calc_cfg_checksum_16()
597 put_unaligned_be16(check_sum, &ts->config[raw_cfg_len]); in goodix_calc_cfg_checksum_16()
598 ts->config[raw_cfg_len + 2] = 1; /* Set "config_fresh" bit */ in goodix_calc_cfg_checksum_16()
602 * goodix_check_cfg - Checks if config fw is valid
612 dev_err(&ts->client->dev, in goodix_check_cfg()
613 "The length of the config fw is not correct"); in goodix_check_cfg()
614 return -EINVAL; in goodix_check_cfg()
617 return ts->chip->check_config(ts, cfg, len); in goodix_check_cfg()
621 * goodix_send_cfg - Write fw config to device
635 error = goodix_i2c_write(ts->client, ts->chip->config_addr, cfg, len); in goodix_send_cfg()
639 dev_dbg(&ts->client->dev, "Config sent successfully."); in goodix_send_cfg()
650 acpi_handle handle = ACPI_HANDLE(&ts->client->dev); in goodix_pin_acpi_direction_input()
654 return ACPI_SUCCESS(status) ? 0 : -EIO; in goodix_pin_acpi_direction_input()
659 acpi_handle handle = ACPI_HANDLE(&ts->client->dev); in goodix_pin_acpi_output_method()
663 return ACPI_SUCCESS(status) ? 0 : -EIO; in goodix_pin_acpi_output_method()
668 dev_err(&ts->client->dev, in goodix_pin_acpi_direction_input()
670 return -EINVAL; in goodix_pin_acpi_direction_input()
675 dev_err(&ts->client->dev, in goodix_pin_acpi_output_method()
677 return -EINVAL; in goodix_pin_acpi_output_method()
683 switch (ts->irq_pin_access_method) { in goodix_irq_direction_output()
685 dev_err(&ts->client->dev, in goodix_irq_direction_output()
688 return -EINVAL; in goodix_irq_direction_output()
690 return gpiod_direction_output(ts->gpiod_int, value); in goodix_irq_direction_output()
694 * as active-low, use output_raw to avoid the value inversion. in goodix_irq_direction_output()
696 return gpiod_direction_output_raw(ts->gpiod_int, value); in goodix_irq_direction_output()
701 return -EINVAL; /* Never reached */ in goodix_irq_direction_output()
706 switch (ts->irq_pin_access_method) { in goodix_irq_direction_input()
708 dev_err(&ts->client->dev, in goodix_irq_direction_input()
711 return -EINVAL; in goodix_irq_direction_input()
713 return gpiod_direction_input(ts->gpiod_int); in goodix_irq_direction_input()
715 return gpiod_direction_input(ts->gpiod_int); in goodix_irq_direction_input()
720 return -EINVAL; /* Never reached */ in goodix_irq_direction_input()
740 dev_err(&ts->client->dev, "Controller irq sync failed.\n"); in goodix_int_sync()
745 * goodix_reset_no_int_sync - Reset device, leaving interrupt line in output mode
754 error = gpiod_direction_output(ts->gpiod_rst, 0); in goodix_reset_no_int_sync()
761 error = goodix_irq_direction_output(ts, ts->client->addr == 0x14); in goodix_reset_no_int_sync()
767 error = gpiod_direction_output(ts->gpiod_rst, 1); in goodix_reset_no_int_sync()
774 * Put the reset pin back in to input / high-impedance mode to save in goodix_reset_no_int_sync()
776 * don't have a pull-up, so there the reset pin must stay active-high. in goodix_reset_no_int_sync()
778 if (ts->irq_pin_access_method == IRQ_PIN_ACCESS_GPIO) { in goodix_reset_no_int_sync()
779 error = gpiod_direction_input(ts->gpiod_rst); in goodix_reset_no_int_sync()
787 dev_err(&ts->client->dev, "Controller reset failed.\n"); in goodix_reset_no_int_sync()
792 * goodix_reset - Reset device during power on
812 { GOODIX_GPIO_INT_NAME "-gpios", &first_gpio, 1 },
813 { GOODIX_GPIO_RST_NAME "-gpios", &second_gpio, 1 },
818 { GOODIX_GPIO_RST_NAME "-gpios", &first_gpio, 1 },
819 { GOODIX_GPIO_INT_NAME "-gpios", &second_gpio, 1 },
824 { GOODIX_GPIO_RST_NAME "-gpios", &first_gpio, 1 },
831 struct device *dev = &ts->client->dev; in goodix_resource()
835 if (ts->gpio_int_idx == -1) { in goodix_resource()
836 ts->gpio_int_idx = ts->gpio_count; in goodix_resource()
839 ts->gpio_int_idx = -2; in goodix_resource()
841 ts->gpio_count++; in goodix_resource()
843 ts->gpio_count++; in goodix_resource()
850 * because the ACPI tables lack GPIO-name to APCI _CRS index mappings
851 * (no _DSD UUID daffd814-6eba-4d8c-8a91-bc9bbf4aa301 data).
853 * retries to get the GPIOs based on the added mapping.
858 struct device *dev = &ts->client->dev; in goodix_add_acpi_gpio_mappings()
862 ts->gpio_count = 0; in goodix_add_acpi_gpio_mappings()
863 ts->gpio_int_idx = -1; in goodix_add_acpi_gpio_mappings()
876 * resource copied from a previous BYT based generation). i2c-core-acpi in goodix_add_acpi_gpio_mappings()
877 * will use the non-working Interrupt resource, fix this up. in goodix_add_acpi_gpio_mappings()
879 if (soc_intel_is_cht() && ts->gpio_count == 2 && ts->gpio_int_idx != -1) { in goodix_add_acpi_gpio_mappings()
881 if (irq > 0 && irq != ts->client->irq) { in goodix_add_acpi_gpio_mappings()
882 dev_warn(dev, "Overriding IRQ %d -> %d\n", ts->client->irq, irq); in goodix_add_acpi_gpio_mappings()
883 ts->client->irq = irq; in goodix_add_acpi_gpio_mappings()
888 if ((ts->gpio_count == 2 || ts->gpio_count == 3) && ts->gpio_int_idx == 0) { in goodix_add_acpi_gpio_mappings()
889 ts->irq_pin_access_method = IRQ_PIN_ACCESS_ACPI_GPIO; in goodix_add_acpi_gpio_mappings()
891 } else if (ts->gpio_count == 2 && ts->gpio_int_idx == 1) { in goodix_add_acpi_gpio_mappings()
892 ts->irq_pin_access_method = IRQ_PIN_ACCESS_ACPI_GPIO; in goodix_add_acpi_gpio_mappings()
894 } else if (ts->gpio_count == 1 && ts->gpio_int_idx == -1 && in goodix_add_acpi_gpio_mappings()
898 ts->irq_pin_access_method = IRQ_PIN_ACCESS_ACPI_METHOD; in goodix_add_acpi_gpio_mappings()
900 } else if (soc_intel_is_byt() && ts->gpio_count == 2 && ts->gpio_int_idx == -1) { in goodix_add_acpi_gpio_mappings()
902 ts->irq_pin_access_method = IRQ_PIN_ACCESS_ACPI_GPIO; in goodix_add_acpi_gpio_mappings()
904 } else if (ts->gpio_count == 1 && ts->gpio_int_idx == 0) { in goodix_add_acpi_gpio_mappings()
921 ts->irq_pin_access_method = IRQ_PIN_ACCESS_NONE; in goodix_add_acpi_gpio_mappings()
925 ts->gpio_count, ts->gpio_int_idx); in goodix_add_acpi_gpio_mappings()
931 return -EINVAL; in goodix_add_acpi_gpio_mappings()
935 * Normally we put the reset pin in input / high-impedance mode to save in goodix_add_acpi_gpio_mappings()
936 * power. But some x86/ACPI boards don't have a pull-up, so for the ACPI in goodix_add_acpi_gpio_mappings()
938 * at all on x86/ACPI boards, except when needed for error-recover. in goodix_add_acpi_gpio_mappings()
940 ts->gpiod_rst_flags = GPIOD_ASIS; in goodix_add_acpi_gpio_mappings()
947 return -EINVAL; in goodix_add_acpi_gpio_mappings()
952 * goodix_get_gpio_config - Get GPIO config from ACPI/DT
962 if (!ts->client) in goodix_get_gpio_config()
963 return -EINVAL; in goodix_get_gpio_config()
964 dev = &ts->client->dev; in goodix_get_gpio_config()
968 * high-impedance when not resetting the controller to save power. in goodix_get_gpio_config()
970 ts->gpiod_rst_flags = GPIOD_IN; in goodix_get_gpio_config()
972 ts->avdd28 = devm_regulator_get(dev, "AVDD28"); in goodix_get_gpio_config()
973 if (IS_ERR(ts->avdd28)) in goodix_get_gpio_config()
974 return dev_err_probe(dev, PTR_ERR(ts->avdd28), "Failed to get AVDD28 regulator\n"); in goodix_get_gpio_config()
976 ts->vddio = devm_regulator_get(dev, "VDDIO"); in goodix_get_gpio_config()
977 if (IS_ERR(ts->vddio)) in goodix_get_gpio_config()
978 return dev_err_probe(dev, PTR_ERR(ts->vddio), "Failed to get VDDIO regulator\n"); in goodix_get_gpio_config()
993 ts->gpiod_int = gpiod; in goodix_get_gpio_config()
996 gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_RST_NAME, ts->gpiod_rst_flags); in goodix_get_gpio_config()
1001 ts->gpiod_rst = gpiod; in goodix_get_gpio_config()
1003 switch (ts->irq_pin_access_method) { in goodix_get_gpio_config()
1009 * Check that we successfully got both GPIOs after we've in goodix_get_gpio_config()
1011 * GPIOs reset irq_pin_access_method to IRQ_PIN_ACCESS_NONE. in goodix_get_gpio_config()
1013 if (!ts->gpiod_int || !ts->gpiod_rst) in goodix_get_gpio_config()
1014 ts->irq_pin_access_method = IRQ_PIN_ACCESS_NONE; in goodix_get_gpio_config()
1017 if (!ts->gpiod_rst) in goodix_get_gpio_config()
1018 ts->irq_pin_access_method = IRQ_PIN_ACCESS_NONE; in goodix_get_gpio_config()
1021 if (ts->gpiod_int && ts->gpiod_rst) { in goodix_get_gpio_config()
1022 ts->reset_controller_at_probe = true; in goodix_get_gpio_config()
1023 ts->load_cfg_from_disk = true; in goodix_get_gpio_config()
1024 ts->irq_pin_access_method = IRQ_PIN_ACCESS_GPIO; in goodix_get_gpio_config()
1032 * goodix_read_config - Read the embedded configuration of the panel
1045 * (controllers without flash) ts->config already has the config in goodix_read_config()
1048 if (!ts->firmware_name) { in goodix_read_config()
1049 error = goodix_i2c_read(ts->client, ts->chip->config_addr, in goodix_read_config()
1050 ts->config, ts->chip->config_len); in goodix_read_config()
1052 ts->int_trigger_type = GOODIX_INT_TRIGGER; in goodix_read_config()
1053 ts->max_touch_num = GOODIX_MAX_CONTACTS; in goodix_read_config()
1058 ts->int_trigger_type = ts->config[TRIGGER_LOC] & 0x03; in goodix_read_config()
1059 ts->max_touch_num = ts->config[MAX_CONTACTS_LOC] & 0x0f; in goodix_read_config()
1061 x_max = get_unaligned_le16(&ts->config[RESOLUTION_LOC]); in goodix_read_config()
1062 y_max = get_unaligned_le16(&ts->config[RESOLUTION_LOC + 2]); in goodix_read_config()
1064 input_abs_set_max(ts->input_dev, ABS_MT_POSITION_X, x_max - 1); in goodix_read_config()
1065 input_abs_set_max(ts->input_dev, ABS_MT_POSITION_Y, y_max - 1); in goodix_read_config()
1068 ts->chip->calc_config_checksum(ts); in goodix_read_config()
1072 * goodix_read_version - Read goodix touchscreen version
1082 error = goodix_i2c_read(ts->client, GOODIX_REG_ID, buf, sizeof(buf)); in goodix_read_version()
1088 strscpy(ts->id, id_str, GOODIX_ID_MAX_LEN + 1); in goodix_read_version()
1090 ts->version = get_unaligned_le16(&buf[4]); in goodix_read_version()
1092 dev_info(&ts->client->dev, "ID %s, version: %04x\n", ts->id, in goodix_read_version()
1093 ts->version); in goodix_read_version()
1099 * goodix_i2c_test - I2C test function to check if the device answers.
1121 * goodix_configure_dev - Finish device initialization
1135 ts->int_trigger_type = GOODIX_INT_TRIGGER; in goodix_configure_dev()
1136 ts->max_touch_num = GOODIX_MAX_CONTACTS; in goodix_configure_dev()
1138 ts->input_dev = devm_input_allocate_device(&ts->client->dev); in goodix_configure_dev()
1139 if (!ts->input_dev) { in goodix_configure_dev()
1140 dev_err(&ts->client->dev, "Failed to allocate input device."); in goodix_configure_dev()
1141 return -ENOMEM; in goodix_configure_dev()
1144 ts->input_dev->name = "Goodix Capacitive TouchScreen"; in goodix_configure_dev()
1145 ts->input_dev->phys = "input/ts"; in goodix_configure_dev()
1146 ts->input_dev->id.bustype = BUS_I2C; in goodix_configure_dev()
1147 ts->input_dev->id.vendor = 0x0416; in goodix_configure_dev()
1148 if (kstrtou16(ts->id, 10, &ts->input_dev->id.product)) in goodix_configure_dev()
1149 ts->input_dev->id.product = 0x1001; in goodix_configure_dev()
1150 ts->input_dev->id.version = ts->version; in goodix_configure_dev()
1152 ts->input_dev->keycode = ts->keymap; in goodix_configure_dev()
1153 ts->input_dev->keycodesize = sizeof(ts->keymap[0]); in goodix_configure_dev()
1154 ts->input_dev->keycodemax = GOODIX_MAX_KEYS; in goodix_configure_dev()
1159 ts->keymap[i] = KEY_LEFTMETA; in goodix_configure_dev()
1161 ts->keymap[i] = KEY_F1 + (i - 1); in goodix_configure_dev()
1163 input_set_capability(ts->input_dev, EV_KEY, ts->keymap[i]); in goodix_configure_dev()
1166 input_set_capability(ts->input_dev, EV_ABS, ABS_MT_POSITION_X); in goodix_configure_dev()
1167 input_set_capability(ts->input_dev, EV_ABS, ABS_MT_POSITION_Y); in goodix_configure_dev()
1168 input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0); in goodix_configure_dev()
1169 input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); in goodix_configure_dev()
1176 touchscreen_parse_properties(ts->input_dev, true, &ts->prop); in goodix_configure_dev()
1178 if (!ts->prop.max_x || !ts->prop.max_y || !ts->max_touch_num) { in goodix_configure_dev()
1179 if (!ts->reset_controller_at_probe && in goodix_configure_dev()
1180 ts->irq_pin_access_method != IRQ_PIN_ACCESS_NONE) { in goodix_configure_dev()
1181 dev_info(&ts->client->dev, "Config not set, resetting controller\n"); in goodix_configure_dev()
1183 ts->reset_controller_at_probe = true; in goodix_configure_dev()
1189 dev_err(&ts->client->dev, in goodix_configure_dev()
1191 ts->prop.max_x, ts->prop.max_y, ts->max_touch_num); in goodix_configure_dev()
1192 ts->prop.max_x = GOODIX_MAX_WIDTH - 1; in goodix_configure_dev()
1193 ts->prop.max_y = GOODIX_MAX_HEIGHT - 1; in goodix_configure_dev()
1194 ts->max_touch_num = GOODIX_MAX_CONTACTS; in goodix_configure_dev()
1195 input_abs_set_max(ts->input_dev, in goodix_configure_dev()
1196 ABS_MT_POSITION_X, ts->prop.max_x); in goodix_configure_dev()
1197 input_abs_set_max(ts->input_dev, in goodix_configure_dev()
1198 ABS_MT_POSITION_Y, ts->prop.max_y); in goodix_configure_dev()
1202 ts->contact_size = 9; in goodix_configure_dev()
1204 dev_dbg(&ts->client->dev, in goodix_configure_dev()
1205 "Non-standard 9-bytes report format quirk\n"); in goodix_configure_dev()
1209 ts->prop.invert_x = true; in goodix_configure_dev()
1210 dev_dbg(&ts->client->dev, in goodix_configure_dev()
1214 error = input_mt_init_slots(ts->input_dev, ts->max_touch_num, in goodix_configure_dev()
1217 dev_err(&ts->client->dev, in goodix_configure_dev()
1222 error = input_register_device(ts->input_dev); in goodix_configure_dev()
1224 dev_err(&ts->client->dev, in goodix_configure_dev()
1240 ts->irq_flags = goodix_irq_flags[ts->int_trigger_type] | IRQF_ONESHOT; in goodix_configure_dev()
1243 dev_err(&ts->client->dev, "request IRQ failed: %d\n", error); in goodix_configure_dev()
1251 * goodix_config_cb - Callback to finish device init
1264 if (ts->firmware_name) { in goodix_config_cb()
1268 error = goodix_check_cfg(ts, cfg->data, cfg->size); in goodix_config_cb()
1272 memcpy(ts->config, cfg->data, cfg->size); in goodix_config_cb()
1275 error = goodix_send_cfg(ts, cfg->data, cfg->size); in goodix_config_cb()
1284 complete_all(&ts->firmware_loading_complete); in goodix_config_cb()
1291 regulator_disable(ts->vddio); in goodix_disable_regulators()
1292 regulator_disable(ts->avdd28); in goodix_disable_regulators()
1301 dev_dbg(&client->dev, "I2C Address: 0x%02x\n", client->addr); in goodix_ts_probe()
1303 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { in goodix_ts_probe()
1304 dev_err(&client->dev, "I2C check functionality failed.\n"); in goodix_ts_probe()
1305 return -ENXIO; in goodix_ts_probe()
1308 ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); in goodix_ts_probe()
1310 return -ENOMEM; in goodix_ts_probe()
1312 ts->client = client; in goodix_ts_probe()
1314 init_completion(&ts->firmware_loading_complete); in goodix_ts_probe()
1315 ts->contact_size = GOODIX_CONTACT_SIZE; in goodix_ts_probe()
1322 error = regulator_enable(ts->avdd28); in goodix_ts_probe()
1324 dev_err(&client->dev, in goodix_ts_probe()
1330 error = regulator_enable(ts->vddio); in goodix_ts_probe()
1332 dev_err(&client->dev, in goodix_ts_probe()
1335 regulator_disable(ts->avdd28); in goodix_ts_probe()
1339 error = devm_add_action_or_reset(&client->dev, in goodix_ts_probe()
1345 if (ts->reset_controller_at_probe) { in goodix_ts_probe()
1354 if (!ts->reset_controller_at_probe && in goodix_ts_probe()
1355 ts->irq_pin_access_method != IRQ_PIN_ACCESS_NONE) { in goodix_ts_probe()
1357 ts->reset_controller_at_probe = true; in goodix_ts_probe()
1360 dev_err(&client->dev, "I2C communication failure: %d\n", error); in goodix_ts_probe()
1372 ts->chip = goodix_get_chip_data(ts->id); in goodix_ts_probe()
1374 if (ts->load_cfg_from_disk) { in goodix_ts_probe()
1376 error = device_property_read_string(&client->dev, in goodix_ts_probe()
1377 "goodix,config-name", in goodix_ts_probe()
1380 snprintf(ts->cfg_name, sizeof(ts->cfg_name), in goodix_ts_probe()
1383 snprintf(ts->cfg_name, sizeof(ts->cfg_name), in goodix_ts_probe()
1384 "goodix_%s_cfg.bin", ts->id); in goodix_ts_probe()
1386 error = request_firmware_nowait(THIS_MODULE, true, ts->cfg_name, in goodix_ts_probe()
1387 &client->dev, GFP_KERNEL, ts, in goodix_ts_probe()
1390 dev_err(&client->dev, in goodix_ts_probe()
1410 if (ts->load_cfg_from_disk) in goodix_ts_remove()
1411 wait_for_completion(&ts->firmware_loading_complete); in goodix_ts_remove()
1420 if (ts->load_cfg_from_disk) in goodix_suspend()
1421 wait_for_completion(&ts->firmware_loading_complete); in goodix_suspend()
1424 if (ts->irq_pin_access_method == IRQ_PIN_ACCESS_NONE) { in goodix_suspend()
1425 disable_irq(client->irq); in goodix_suspend()
1444 error = goodix_i2c_write_u8(ts->client, GOODIX_REG_COMMAND, in goodix_suspend()
1449 return -EAGAIN; in goodix_suspend()
1453 * The datasheet specifies that the interval between sending screen-off in goodix_suspend()
1454 * command and wake-up should be longer than 58 ms. To avoid waking up in goodix_suspend()
1468 if (ts->irq_pin_access_method == IRQ_PIN_ACCESS_NONE) { in goodix_resume()
1469 enable_irq(client->irq); in goodix_resume()
1487 error = goodix_i2c_read(ts->client, ts->chip->config_addr, in goodix_resume()
1489 if (!error && config_ver != ts->config[0]) in goodix_resume()
1491 config_ver, ts->config[0]); in goodix_resume()
1493 if (error != 0 || config_ver != ts->config[0]) { in goodix_resume()
1498 error = goodix_send_cfg(ts, ts->config, ts->chip->config_len); in goodix_resume()
1554 .name = "Goodix-TS",