Lines Matching refs:ts
61 static int goodix_check_cfg_8(struct goodix_ts_data *ts,
63 static int goodix_check_cfg_16(struct goodix_ts_data *ts,
65 static void goodix_calc_cfg_checksum_8(struct goodix_ts_data *ts);
66 static void goodix_calc_cfg_checksum_16(struct goodix_ts_data *ts);
251 static int goodix_ts_read_input_report(struct goodix_ts_data *ts, u8 *data) in goodix_ts_read_input_report() argument
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()
284 error = goodix_i2c_read(ts->client, in goodix_ts_read_input_report()
286 ts->contact_size * in goodix_ts_read_input_report()
295 if (data[0] == 0 && ts->firmware_name) { in goodix_ts_read_input_report()
296 if (goodix_handle_fw_request(ts)) in goodix_ts_read_input_report()
310 static int goodix_create_pen_input(struct goodix_ts_data *ts) in goodix_create_pen_input() argument
312 struct device *dev = &ts->client->dev; 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()
340 if (kstrtou16(ts->id, 10, &input->id.product)) 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()
348 static void goodix_ts_report_pen_down(struct goodix_ts_data *ts, u8 *data) in goodix_ts_report_pen_down() argument
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()
389 static void goodix_ts_report_pen_up(struct goodix_ts_data *ts) in goodix_ts_report_pen_up() argument
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()
402 static void goodix_ts_report_touch_8b(struct goodix_ts_data *ts, u8 *coor_data) in goodix_ts_report_touch_8b() argument
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()
417 static void goodix_ts_report_touch_9b(struct goodix_ts_data *ts, u8 *coor_data) in goodix_ts_report_touch_9b() argument
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()
432 static void goodix_ts_release_keys(struct goodix_ts_data *ts) in goodix_ts_release_keys() argument
437 input_report_key(ts->input_dev, ts->keymap[i], 0); in goodix_ts_release_keys()
440 static void goodix_ts_report_key(struct goodix_ts_data *ts, u8 *data) in goodix_ts_report_key() argument
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()
454 goodix_ts_release_keys(ts); in goodix_ts_report_key()
466 static void goodix_process_events(struct goodix_ts_data *ts) in goodix_process_events() argument
472 touch_num = goodix_ts_read_input_report(ts, point_data); in goodix_process_events()
478 goodix_ts_report_pen_down(ts, point_data); in goodix_process_events()
479 goodix_ts_release_keys(ts); in goodix_process_events()
482 goodix_ts_report_pen_up(ts); in goodix_process_events()
485 goodix_ts_report_key(ts, point_data); in goodix_process_events()
488 if (ts->contact_size == 9) in goodix_process_events()
489 goodix_ts_report_touch_9b(ts, in goodix_process_events()
490 &point_data[1 + ts->contact_size * i]); in goodix_process_events()
492 goodix_ts_report_touch_8b(ts, 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()
508 struct goodix_ts_data *ts = dev_id; in goodix_ts_irq_handler() local
510 goodix_process_events(ts); in goodix_ts_irq_handler()
511 goodix_i2c_write_u8(ts->client, GOODIX_READ_COOR_ADDR, 0); in goodix_ts_irq_handler()
516 static void goodix_free_irq(struct goodix_ts_data *ts) in goodix_free_irq() argument
518 devm_free_irq(&ts->client->dev, ts->client->irq, ts); in goodix_free_irq()
521 static int goodix_request_irq(struct goodix_ts_data *ts) in goodix_request_irq() argument
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()
528 static int goodix_check_cfg_8(struct goodix_ts_data *ts, const u8 *cfg, int len) in goodix_check_cfg_8() argument
537 dev_err(&ts->client->dev, in goodix_check_cfg_8()
543 dev_err(&ts->client->dev, in goodix_check_cfg_8()
551 static void goodix_calc_cfg_checksum_8(struct goodix_ts_data *ts) in goodix_calc_cfg_checksum_8() argument
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()
564 static int goodix_check_cfg_16(struct goodix_ts_data *ts, const u8 *cfg, in goodix_check_cfg_16() argument
574 dev_err(&ts->client->dev, in goodix_check_cfg_16()
580 dev_err(&ts->client->dev, in goodix_check_cfg_16()
588 static void goodix_calc_cfg_checksum_16(struct goodix_ts_data *ts) in goodix_calc_cfg_checksum_16() argument
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()
608 static int goodix_check_cfg(struct goodix_ts_data *ts, const u8 *cfg, int len) in goodix_check_cfg() argument
612 dev_err(&ts->client->dev, in goodix_check_cfg()
617 return ts->chip->check_config(ts, cfg, len); in goodix_check_cfg()
627 int goodix_send_cfg(struct goodix_ts_data *ts, const u8 *cfg, int len) in goodix_send_cfg() argument
631 error = goodix_check_cfg(ts, cfg, len); in goodix_send_cfg()
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()
648 static int goodix_pin_acpi_direction_input(struct goodix_ts_data *ts) in goodix_pin_acpi_direction_input() argument
650 acpi_handle handle = ACPI_HANDLE(&ts->client->dev); in goodix_pin_acpi_direction_input()
657 static int goodix_pin_acpi_output_method(struct goodix_ts_data *ts, int value) in goodix_pin_acpi_output_method() argument
659 acpi_handle handle = ACPI_HANDLE(&ts->client->dev); in goodix_pin_acpi_output_method()
666 static int goodix_pin_acpi_direction_input(struct goodix_ts_data *ts) in goodix_pin_acpi_direction_input() argument
668 dev_err(&ts->client->dev, in goodix_pin_acpi_direction_input()
673 static int goodix_pin_acpi_output_method(struct goodix_ts_data *ts, int value) in goodix_pin_acpi_output_method() argument
675 dev_err(&ts->client->dev, in goodix_pin_acpi_output_method()
681 static int goodix_irq_direction_output(struct goodix_ts_data *ts, int value) in goodix_irq_direction_output() argument
683 switch (ts->irq_pin_access_method) { in goodix_irq_direction_output()
685 dev_err(&ts->client->dev, in goodix_irq_direction_output()
690 return gpiod_direction_output(ts->gpiod_int, value); in goodix_irq_direction_output()
696 return gpiod_direction_output_raw(ts->gpiod_int, value); in goodix_irq_direction_output()
698 return goodix_pin_acpi_output_method(ts, value); in goodix_irq_direction_output()
704 static int goodix_irq_direction_input(struct goodix_ts_data *ts) in goodix_irq_direction_input() argument
706 switch (ts->irq_pin_access_method) { in goodix_irq_direction_input()
708 dev_err(&ts->client->dev, 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()
717 return goodix_pin_acpi_direction_input(ts); in goodix_irq_direction_input()
723 int goodix_int_sync(struct goodix_ts_data *ts) in goodix_int_sync() argument
727 error = goodix_irq_direction_output(ts, 0); in goodix_int_sync()
733 error = goodix_irq_direction_input(ts); in goodix_int_sync()
740 dev_err(&ts->client->dev, "Controller irq sync failed.\n"); in goodix_int_sync()
749 int goodix_reset_no_int_sync(struct goodix_ts_data *ts) in goodix_reset_no_int_sync() argument
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()
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()
796 static int goodix_reset(struct goodix_ts_data *ts) in goodix_reset() argument
800 error = goodix_reset_no_int_sync(ts); in goodix_reset()
804 return goodix_int_sync(ts); in goodix_reset()
830 struct goodix_ts_data *ts = data; in goodix_resource() local
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()
855 static int goodix_add_acpi_gpio_mappings(struct goodix_ts_data *ts) in goodix_add_acpi_gpio_mappings() argument
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()
865 goodix_resource, ts); 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()
940 ts->gpiod_rst_flags = GPIOD_ASIS; in goodix_add_acpi_gpio_mappings()
945 static int goodix_add_acpi_gpio_mappings(struct goodix_ts_data *ts) in goodix_add_acpi_gpio_mappings() argument
956 static int goodix_get_gpio_config(struct goodix_ts_data *ts) in goodix_get_gpio_config() argument
962 if (!ts->client) in goodix_get_gpio_config()
964 dev = &ts->client->dev; 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()
989 if (goodix_add_acpi_gpio_mappings(ts) == 0) 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()
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()
1038 static void goodix_read_config(struct goodix_ts_data *ts) in goodix_read_config() argument
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()
1076 static int goodix_read_version(struct goodix_ts_data *ts) in goodix_read_version() argument
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()
1130 static int goodix_configure_dev(struct goodix_ts_data *ts) in goodix_configure_dev() argument
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()
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()
1173 goodix_read_config(ts); 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()
1184 error = goodix_reset(ts); 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()
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()
1236 error = goodix_create_pen_input(ts); in goodix_configure_dev()
1240 ts->irq_flags = goodix_irq_flags[ts->int_trigger_type] | IRQF_ONESHOT; in goodix_configure_dev()
1241 error = goodix_request_irq(ts); in goodix_configure_dev()
1243 dev_err(&ts->client->dev, "request IRQ failed: %d\n", error); in goodix_configure_dev()
1261 struct goodix_ts_data *ts = ctx; in goodix_config_cb() local
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()
1280 goodix_configure_dev(ts); in goodix_config_cb()
1284 complete_all(&ts->firmware_loading_complete); in goodix_config_cb()
1289 struct goodix_ts_data *ts = arg; in goodix_disable_regulators() local
1291 regulator_disable(ts->vddio); in goodix_disable_regulators()
1292 regulator_disable(ts->avdd28); in goodix_disable_regulators()
1297 struct goodix_ts_data *ts; in goodix_ts_probe() local
1308 ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); in goodix_ts_probe()
1309 if (!ts) in goodix_ts_probe()
1312 ts->client = client; in goodix_ts_probe()
1313 i2c_set_clientdata(client, ts); 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()
1317 error = goodix_get_gpio_config(ts); in goodix_ts_probe()
1322 error = regulator_enable(ts->avdd28); in goodix_ts_probe()
1330 error = regulator_enable(ts->vddio); in goodix_ts_probe()
1335 regulator_disable(ts->avdd28); in goodix_ts_probe()
1340 goodix_disable_regulators, ts); in goodix_ts_probe()
1345 if (ts->reset_controller_at_probe) { in goodix_ts_probe()
1347 error = goodix_reset(ts); 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()
1364 error = goodix_firmware_check(ts); in goodix_ts_probe()
1368 error = goodix_read_version(ts); 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()
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()
1398 error = goodix_configure_dev(ts); in goodix_ts_probe()
1408 struct goodix_ts_data *ts = i2c_get_clientdata(client); in goodix_ts_remove() local
1410 if (ts->load_cfg_from_disk) in goodix_ts_remove()
1411 wait_for_completion(&ts->firmware_loading_complete); in goodix_ts_remove()
1417 struct goodix_ts_data *ts = i2c_get_clientdata(client); in goodix_suspend() local
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()
1430 goodix_free_irq(ts); in goodix_suspend()
1433 goodix_save_bak_ref(ts); in goodix_suspend()
1436 error = goodix_irq_direction_output(ts, 0); in goodix_suspend()
1438 goodix_request_irq(ts); in goodix_suspend()
1444 error = goodix_i2c_write_u8(ts->client, GOODIX_REG_COMMAND, in goodix_suspend()
1447 goodix_irq_direction_input(ts); in goodix_suspend()
1448 goodix_request_irq(ts); in goodix_suspend()
1464 struct goodix_ts_data *ts = i2c_get_clientdata(client); in goodix_resume() local
1468 if (ts->irq_pin_access_method == IRQ_PIN_ACCESS_NONE) { in goodix_resume()
1477 error = goodix_irq_direction_output(ts, 1); in goodix_resume()
1483 error = goodix_int_sync(ts); 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()
1494 error = goodix_reset(ts); in goodix_resume()
1498 error = goodix_send_cfg(ts, ts->config, ts->chip->config_len); in goodix_resume()
1503 error = goodix_request_irq(ts); in goodix_resume()