Lines Matching refs:tsdata

154 static bool edt_ft5x06_ts_check_crc(struct edt_ft5x06_ts_data *tsdata,  in edt_ft5x06_ts_check_crc()  argument
164 dev_err_ratelimited(&tsdata->client->dev, in edt_ft5x06_ts_check_crc()
175 struct edt_ft5x06_ts_data *tsdata = dev_id; in edt_ft5x06_ts_isr() local
176 struct device *dev = &tsdata->client->dev; in edt_ft5x06_ts_isr()
183 switch (tsdata->version) { in edt_ft5x06_ts_isr()
205 datalen = tplen * tsdata->max_support_points + offset + crclen; in edt_ft5x06_ts_isr()
207 error = edt_ft5x06_ts_readwrite(tsdata->client, in edt_ft5x06_ts_isr()
217 if (tsdata->version == EDT_M06) { in edt_ft5x06_ts_isr()
226 if (!edt_ft5x06_ts_check_crc(tsdata, rdbuf, datalen)) in edt_ft5x06_ts_isr()
230 for (i = 0; i < tsdata->max_support_points; i++) { in edt_ft5x06_ts_isr()
240 if (tsdata->version == EDT_M06 && type == TOUCH_EVENT_DOWN) in edt_ft5x06_ts_isr()
248 input_mt_slot(tsdata->input, id); in edt_ft5x06_ts_isr()
249 input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, down); in edt_ft5x06_ts_isr()
254 touchscreen_report_pos(tsdata->input, &tsdata->prop, x, y, in edt_ft5x06_ts_isr()
258 input_mt_report_pointer_emulation(tsdata->input, true); in edt_ft5x06_ts_isr()
259 input_sync(tsdata->input); in edt_ft5x06_ts_isr()
265 static int edt_ft5x06_register_write(struct edt_ft5x06_ts_data *tsdata, in edt_ft5x06_register_write() argument
270 switch (tsdata->version) { in edt_ft5x06_register_write()
272 wrbuf[0] = tsdata->factory_mode ? 0xf3 : 0xfc; in edt_ft5x06_register_write()
273 wrbuf[1] = tsdata->factory_mode ? addr & 0x7f : addr & 0x3f; in edt_ft5x06_register_write()
276 return edt_ft5x06_ts_readwrite(tsdata->client, 4, in edt_ft5x06_register_write()
284 return edt_ft5x06_ts_readwrite(tsdata->client, 2, in edt_ft5x06_register_write()
292 static int edt_ft5x06_register_read(struct edt_ft5x06_ts_data *tsdata, in edt_ft5x06_register_read() argument
298 switch (tsdata->version) { in edt_ft5x06_register_read()
300 wrbuf[0] = tsdata->factory_mode ? 0xf3 : 0xfc; in edt_ft5x06_register_read()
301 wrbuf[1] = tsdata->factory_mode ? addr & 0x7f : addr & 0x3f; in edt_ft5x06_register_read()
302 wrbuf[1] |= tsdata->factory_mode ? 0x80 : 0x40; in edt_ft5x06_register_read()
304 error = edt_ft5x06_ts_readwrite(tsdata->client, 2, wrbuf, 2, in edt_ft5x06_register_read()
310 dev_err(&tsdata->client->dev, in edt_ft5x06_register_read()
322 error = edt_ft5x06_ts_readwrite(tsdata->client, 1, in edt_ft5x06_register_read()
362 struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client); in edt_ft5x06_setting_show() local
365 u8 *field = (u8 *)tsdata + attr->field_offset; in edt_ft5x06_setting_show()
371 mutex_lock(&tsdata->mutex); in edt_ft5x06_setting_show()
373 if (tsdata->factory_mode) { in edt_ft5x06_setting_show()
378 switch (tsdata->version) { in edt_ft5x06_setting_show()
395 val = edt_ft5x06_register_read(tsdata, addr); in edt_ft5x06_setting_show()
398 dev_err(&tsdata->client->dev, in edt_ft5x06_setting_show()
408 dev_warn(&tsdata->client->dev, in edt_ft5x06_setting_show()
416 mutex_unlock(&tsdata->mutex); in edt_ft5x06_setting_show()
425 struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client); in edt_ft5x06_setting_store() local
428 u8 *field = (u8 *)tsdata + attr->field_offset; in edt_ft5x06_setting_store()
433 mutex_lock(&tsdata->mutex); in edt_ft5x06_setting_store()
435 if (tsdata->factory_mode) { in edt_ft5x06_setting_store()
449 switch (tsdata->version) { in edt_ft5x06_setting_store()
466 error = edt_ft5x06_register_write(tsdata, addr, val); in edt_ft5x06_setting_store()
468 dev_err(&tsdata->client->dev, in edt_ft5x06_setting_store()
477 mutex_unlock(&tsdata->mutex); in edt_ft5x06_setting_store()
507 static int edt_ft5x06_factory_mode(struct edt_ft5x06_ts_data *tsdata) in edt_ft5x06_factory_mode() argument
509 struct i2c_client *client = tsdata->client; in edt_ft5x06_factory_mode()
514 if (tsdata->version != EDT_M06) { in edt_ft5x06_factory_mode()
522 if (!tsdata->raw_buffer) { in edt_ft5x06_factory_mode()
523 tsdata->raw_bufsize = tsdata->num_x * tsdata->num_y * in edt_ft5x06_factory_mode()
525 tsdata->raw_buffer = kzalloc(tsdata->raw_bufsize, GFP_KERNEL); in edt_ft5x06_factory_mode()
526 if (!tsdata->raw_buffer) { in edt_ft5x06_factory_mode()
533 error = edt_ft5x06_register_write(tsdata, WORK_REGISTER_OPMODE, 0x03); in edt_ft5x06_factory_mode()
540 tsdata->factory_mode = true; in edt_ft5x06_factory_mode()
544 ret = edt_ft5x06_register_read(tsdata, FACTORY_REGISTER_OPMODE); in edt_ft5x06_factory_mode()
559 kfree(tsdata->raw_buffer); in edt_ft5x06_factory_mode()
560 tsdata->raw_buffer = NULL; in edt_ft5x06_factory_mode()
561 tsdata->factory_mode = false; in edt_ft5x06_factory_mode()
567 static int edt_ft5x06_work_mode(struct edt_ft5x06_ts_data *tsdata) in edt_ft5x06_work_mode() argument
569 struct i2c_client *client = tsdata->client; in edt_ft5x06_work_mode()
571 struct edt_reg_addr *reg_addr = &tsdata->reg_addr; in edt_ft5x06_work_mode()
576 error = edt_ft5x06_register_write(tsdata, FACTORY_REGISTER_OPMODE, 0x1); in edt_ft5x06_work_mode()
583 tsdata->factory_mode = false; in edt_ft5x06_work_mode()
588 ret = edt_ft5x06_register_read(tsdata, WORK_REGISTER_OPMODE); in edt_ft5x06_work_mode()
596 tsdata->factory_mode = true; in edt_ft5x06_work_mode()
600 kfree(tsdata->raw_buffer); in edt_ft5x06_work_mode()
601 tsdata->raw_buffer = NULL; in edt_ft5x06_work_mode()
604 edt_ft5x06_register_write(tsdata, reg_addr->reg_threshold, in edt_ft5x06_work_mode()
605 tsdata->threshold); in edt_ft5x06_work_mode()
606 edt_ft5x06_register_write(tsdata, reg_addr->reg_gain, in edt_ft5x06_work_mode()
607 tsdata->gain); in edt_ft5x06_work_mode()
608 edt_ft5x06_register_write(tsdata, reg_addr->reg_offset, in edt_ft5x06_work_mode()
609 tsdata->offset); in edt_ft5x06_work_mode()
611 edt_ft5x06_register_write(tsdata, reg_addr->reg_report_rate, in edt_ft5x06_work_mode()
612 tsdata->report_rate); in edt_ft5x06_work_mode()
621 struct edt_ft5x06_ts_data *tsdata = data; in edt_ft5x06_debugfs_mode_get() local
623 *mode = tsdata->factory_mode; in edt_ft5x06_debugfs_mode_get()
630 struct edt_ft5x06_ts_data *tsdata = data; in edt_ft5x06_debugfs_mode_set() local
636 mutex_lock(&tsdata->mutex); in edt_ft5x06_debugfs_mode_set()
638 if (mode != tsdata->factory_mode) { in edt_ft5x06_debugfs_mode_set()
639 retval = mode ? edt_ft5x06_factory_mode(tsdata) : in edt_ft5x06_debugfs_mode_set()
640 edt_ft5x06_work_mode(tsdata); in edt_ft5x06_debugfs_mode_set()
643 mutex_unlock(&tsdata->mutex); in edt_ft5x06_debugfs_mode_set()
654 struct edt_ft5x06_ts_data *tsdata = file->private_data; in edt_ft5x06_debugfs_raw_data_read() local
655 struct i2c_client *client = tsdata->client; in edt_ft5x06_debugfs_raw_data_read()
663 if (*off < 0 || *off >= tsdata->raw_bufsize) in edt_ft5x06_debugfs_raw_data_read()
666 mutex_lock(&tsdata->mutex); in edt_ft5x06_debugfs_raw_data_read()
668 if (!tsdata->factory_mode || !tsdata->raw_buffer) { in edt_ft5x06_debugfs_raw_data_read()
673 error = edt_ft5x06_register_write(tsdata, 0x08, 0x01); in edt_ft5x06_debugfs_raw_data_read()
682 val = edt_ft5x06_register_read(tsdata, 0x08); in edt_ft5x06_debugfs_raw_data_read()
701 rdbuf = tsdata->raw_buffer; in edt_ft5x06_debugfs_raw_data_read()
702 colbytes = tsdata->num_y * sizeof(u16); in edt_ft5x06_debugfs_raw_data_read()
706 for (i = 0; i < tsdata->num_x; i++) { in edt_ft5x06_debugfs_raw_data_read()
708 error = edt_ft5x06_ts_readwrite(tsdata->client, in edt_ft5x06_debugfs_raw_data_read()
717 read = min_t(size_t, count, tsdata->raw_bufsize - *off); in edt_ft5x06_debugfs_raw_data_read()
718 if (copy_to_user(buf, tsdata->raw_buffer + *off, read)) { in edt_ft5x06_debugfs_raw_data_read()
725 mutex_unlock(&tsdata->mutex); in edt_ft5x06_debugfs_raw_data_read()
735 edt_ft5x06_ts_prepare_debugfs(struct edt_ft5x06_ts_data *tsdata, in edt_ft5x06_ts_prepare_debugfs() argument
738 tsdata->debug_dir = debugfs_create_dir(debugfs_name, NULL); in edt_ft5x06_ts_prepare_debugfs()
739 if (!tsdata->debug_dir) in edt_ft5x06_ts_prepare_debugfs()
742 debugfs_create_u16("num_x", S_IRUSR, tsdata->debug_dir, &tsdata->num_x); in edt_ft5x06_ts_prepare_debugfs()
743 debugfs_create_u16("num_y", S_IRUSR, tsdata->debug_dir, &tsdata->num_y); in edt_ft5x06_ts_prepare_debugfs()
746 tsdata->debug_dir, tsdata, &debugfs_mode_fops); in edt_ft5x06_ts_prepare_debugfs()
748 tsdata->debug_dir, tsdata, &debugfs_raw_data_fops); in edt_ft5x06_ts_prepare_debugfs()
752 edt_ft5x06_ts_teardown_debugfs(struct edt_ft5x06_ts_data *tsdata) in edt_ft5x06_ts_teardown_debugfs() argument
754 debugfs_remove_recursive(tsdata->debug_dir); in edt_ft5x06_ts_teardown_debugfs()
755 kfree(tsdata->raw_buffer); in edt_ft5x06_ts_teardown_debugfs()
761 edt_ft5x06_ts_prepare_debugfs(struct edt_ft5x06_ts_data *tsdata, in edt_ft5x06_ts_prepare_debugfs() argument
767 edt_ft5x06_ts_teardown_debugfs(struct edt_ft5x06_ts_data *tsdata) in edt_ft5x06_ts_teardown_debugfs() argument
774 struct edt_ft5x06_ts_data *tsdata, in edt_ft5x06_ts_identify() argument
780 char *model_name = tsdata->name; in edt_ft5x06_ts_identify()
797 tsdata->version = EDT_M06; in edt_ft5x06_ts_identify()
811 tsdata->version = EDT_M12; in edt_ft5x06_ts_identify()
834 tsdata->version = GENERIC_FT; in edt_ft5x06_ts_identify()
858 tsdata->version = EDT_M09; in edt_ft5x06_ts_identify()
863 tsdata->version = EDT_M09; in edt_ft5x06_ts_identify()
882 struct edt_ft5x06_ts_data *tsdata) in edt_ft5x06_ts_get_defaults() argument
884 struct edt_reg_addr *reg_addr = &tsdata->reg_addr; in edt_ft5x06_ts_get_defaults()
890 edt_ft5x06_register_write(tsdata, reg_addr->reg_threshold, val); in edt_ft5x06_ts_get_defaults()
891 tsdata->threshold = val; in edt_ft5x06_ts_get_defaults()
896 edt_ft5x06_register_write(tsdata, reg_addr->reg_gain, val); in edt_ft5x06_ts_get_defaults()
897 tsdata->gain = val; in edt_ft5x06_ts_get_defaults()
902 edt_ft5x06_register_write(tsdata, reg_addr->reg_offset, val); in edt_ft5x06_ts_get_defaults()
903 tsdata->offset = val; in edt_ft5x06_ts_get_defaults()
908 edt_ft5x06_ts_get_parameters(struct edt_ft5x06_ts_data *tsdata) in edt_ft5x06_ts_get_parameters() argument
910 struct edt_reg_addr *reg_addr = &tsdata->reg_addr; in edt_ft5x06_ts_get_parameters()
912 tsdata->threshold = edt_ft5x06_register_read(tsdata, in edt_ft5x06_ts_get_parameters()
914 tsdata->gain = edt_ft5x06_register_read(tsdata, reg_addr->reg_gain); in edt_ft5x06_ts_get_parameters()
915 tsdata->offset = edt_ft5x06_register_read(tsdata, reg_addr->reg_offset); in edt_ft5x06_ts_get_parameters()
917 tsdata->report_rate = edt_ft5x06_register_read(tsdata, in edt_ft5x06_ts_get_parameters()
919 if (tsdata->version == EDT_M06 || in edt_ft5x06_ts_get_parameters()
920 tsdata->version == EDT_M09 || in edt_ft5x06_ts_get_parameters()
921 tsdata->version == EDT_M12) { in edt_ft5x06_ts_get_parameters()
922 tsdata->num_x = edt_ft5x06_register_read(tsdata, in edt_ft5x06_ts_get_parameters()
924 tsdata->num_y = edt_ft5x06_register_read(tsdata, in edt_ft5x06_ts_get_parameters()
927 tsdata->num_x = -1; in edt_ft5x06_ts_get_parameters()
928 tsdata->num_y = -1; in edt_ft5x06_ts_get_parameters()
933 edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata) in edt_ft5x06_ts_set_regs() argument
935 struct edt_reg_addr *reg_addr = &tsdata->reg_addr; in edt_ft5x06_ts_set_regs()
937 switch (tsdata->version) { in edt_ft5x06_ts_set_regs()
970 struct edt_ft5x06_ts_data *tsdata; in edt_ft5x06_ts_probe() local
978 tsdata = devm_kzalloc(&client->dev, sizeof(*tsdata), GFP_KERNEL); in edt_ft5x06_ts_probe()
979 if (!tsdata) { in edt_ft5x06_ts_probe()
992 tsdata->max_support_points = chip_data->max_support_points; in edt_ft5x06_ts_probe()
994 tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev, in edt_ft5x06_ts_probe()
996 if (IS_ERR(tsdata->reset_gpio)) { in edt_ft5x06_ts_probe()
997 error = PTR_ERR(tsdata->reset_gpio); in edt_ft5x06_ts_probe()
1003 tsdata->wake_gpio = devm_gpiod_get_optional(&client->dev, in edt_ft5x06_ts_probe()
1005 if (IS_ERR(tsdata->wake_gpio)) { in edt_ft5x06_ts_probe()
1006 error = PTR_ERR(tsdata->wake_gpio); in edt_ft5x06_ts_probe()
1012 if (tsdata->wake_gpio) { in edt_ft5x06_ts_probe()
1014 gpiod_set_value_cansleep(tsdata->wake_gpio, 1); in edt_ft5x06_ts_probe()
1017 if (tsdata->reset_gpio) { in edt_ft5x06_ts_probe()
1019 gpiod_set_value_cansleep(tsdata->reset_gpio, 0); in edt_ft5x06_ts_probe()
1029 mutex_init(&tsdata->mutex); in edt_ft5x06_ts_probe()
1030 tsdata->client = client; in edt_ft5x06_ts_probe()
1031 tsdata->input = input; in edt_ft5x06_ts_probe()
1032 tsdata->factory_mode = false; in edt_ft5x06_ts_probe()
1034 error = edt_ft5x06_ts_identify(client, tsdata, fw_version); in edt_ft5x06_ts_probe()
1040 edt_ft5x06_ts_set_regs(tsdata); in edt_ft5x06_ts_probe()
1041 edt_ft5x06_ts_get_defaults(&client->dev, tsdata); in edt_ft5x06_ts_probe()
1042 edt_ft5x06_ts_get_parameters(tsdata); in edt_ft5x06_ts_probe()
1046 tsdata->name, fw_version, tsdata->num_x, tsdata->num_y); in edt_ft5x06_ts_probe()
1048 input->name = tsdata->name; in edt_ft5x06_ts_probe()
1052 if (tsdata->version == EDT_M06 || in edt_ft5x06_ts_probe()
1053 tsdata->version == EDT_M09 || in edt_ft5x06_ts_probe()
1054 tsdata->version == EDT_M12) { in edt_ft5x06_ts_probe()
1056 0, tsdata->num_x * 64 - 1, 0, 0); in edt_ft5x06_ts_probe()
1058 0, tsdata->num_y * 64 - 1, 0, 0); in edt_ft5x06_ts_probe()
1067 touchscreen_parse_properties(input, true, &tsdata->prop); in edt_ft5x06_ts_probe()
1069 error = input_mt_init_slots(input, tsdata->max_support_points, in edt_ft5x06_ts_probe()
1076 i2c_set_clientdata(client, tsdata); in edt_ft5x06_ts_probe()
1085 client->name, tsdata); in edt_ft5x06_ts_probe()
1099 edt_ft5x06_ts_prepare_debugfs(tsdata, dev_driver_string(&client->dev)); in edt_ft5x06_ts_probe()
1105 tsdata->wake_gpio ? desc_to_gpio(tsdata->wake_gpio) : -1, in edt_ft5x06_ts_probe()
1106 tsdata->reset_gpio ? desc_to_gpio(tsdata->reset_gpio) : -1); in edt_ft5x06_ts_probe()
1113 struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client); in edt_ft5x06_ts_remove() local
1115 edt_ft5x06_ts_teardown_debugfs(tsdata); in edt_ft5x06_ts_remove()