Lines Matching +full:iovcc +full:- +full:supply

1 // SPDX-License-Identifier: GPL-2.0
5 * Lothar Waßmann <LW@KARO-electronics.de> (DT support)
110 struct regulator *iovcc; member
154 wrmsg[i].addr = client->addr; in edt_ft5x06_ts_readwrite()
161 wrmsg[i].addr = client->addr; in edt_ft5x06_ts_readwrite()
168 ret = i2c_transfer(client->adapter, wrmsg, i); in edt_ft5x06_ts_readwrite()
172 return -EIO; in edt_ft5x06_ts_readwrite()
183 for (i = 0; i < buflen - 1; i++) in edt_ft5x06_ts_check_crc()
186 if (crc != buf[buflen-1]) { in edt_ft5x06_ts_check_crc()
187 tsdata->crc_errors++; in edt_ft5x06_ts_check_crc()
188 dev_err_ratelimited(&tsdata->client->dev, in edt_ft5x06_ts_check_crc()
190 crc, buf[buflen-1]); in edt_ft5x06_ts_check_crc()
200 struct device *dev = &tsdata->client->dev; in edt_ft5x06_ts_isr()
207 switch (tsdata->version) { in edt_ft5x06_ts_isr()
230 datalen = tplen * tsdata->max_support_points + offset + crclen; in edt_ft5x06_ts_isr()
232 error = edt_ft5x06_ts_readwrite(tsdata->client, in edt_ft5x06_ts_isr()
242 if (tsdata->version == EDT_M06) { in edt_ft5x06_ts_isr()
245 tsdata->header_errors++; in edt_ft5x06_ts_isr()
256 for (i = 0; i < tsdata->max_support_points; i++) { in edt_ft5x06_ts_isr()
265 if (tsdata->version == EDT_M06 && type == TOUCH_EVENT_DOWN) in edt_ft5x06_ts_isr()
271 if (tsdata->version == EV_FT) in edt_ft5x06_ts_isr()
276 input_mt_slot(tsdata->input, id); in edt_ft5x06_ts_isr()
277 if (input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, in edt_ft5x06_ts_isr()
279 touchscreen_report_pos(tsdata->input, &tsdata->prop, in edt_ft5x06_ts_isr()
283 input_mt_report_pointer_emulation(tsdata->input, true); in edt_ft5x06_ts_isr()
284 input_sync(tsdata->input); in edt_ft5x06_ts_isr()
295 switch (tsdata->version) { in edt_ft5x06_register_write()
297 wrbuf[0] = tsdata->factory_mode ? 0xf3 : 0xfc; in edt_ft5x06_register_write()
298 wrbuf[1] = tsdata->factory_mode ? addr & 0x7f : addr & 0x3f; in edt_ft5x06_register_write()
301 return edt_ft5x06_ts_readwrite(tsdata->client, 4, in edt_ft5x06_register_write()
311 return edt_ft5x06_ts_readwrite(tsdata->client, 2, in edt_ft5x06_register_write()
315 return -EINVAL; in edt_ft5x06_register_write()
325 switch (tsdata->version) { in edt_ft5x06_register_read()
327 wrbuf[0] = tsdata->factory_mode ? 0xf3 : 0xfc; in edt_ft5x06_register_read()
328 wrbuf[1] = tsdata->factory_mode ? addr & 0x7f : addr & 0x3f; in edt_ft5x06_register_read()
329 wrbuf[1] |= tsdata->factory_mode ? 0x80 : 0x40; in edt_ft5x06_register_read()
331 error = edt_ft5x06_ts_readwrite(tsdata->client, 2, wrbuf, 2, in edt_ft5x06_register_read()
337 dev_err(&tsdata->client->dev, in edt_ft5x06_register_read()
341 return -EIO; in edt_ft5x06_register_read()
350 error = edt_ft5x06_ts_readwrite(tsdata->client, 1, in edt_ft5x06_register_read()
357 return -EINVAL; in edt_ft5x06_register_read()
395 u8 *field = (u8 *)tsdata + attr->field_offset; in edt_ft5x06_setting_show()
401 mutex_lock(&tsdata->mutex); in edt_ft5x06_setting_show()
403 if (tsdata->factory_mode) { in edt_ft5x06_setting_show()
404 error = -EIO; in edt_ft5x06_setting_show()
408 switch (tsdata->version) { in edt_ft5x06_setting_show()
410 addr = attr->addr_m06; in edt_ft5x06_setting_show()
416 addr = attr->addr_m09; in edt_ft5x06_setting_show()
420 addr = attr->addr_ev; in edt_ft5x06_setting_show()
424 error = -ENODEV; in edt_ft5x06_setting_show()
432 dev_err(&tsdata->client->dev, in edt_ft5x06_setting_show()
434 dattr->attr.name, error); in edt_ft5x06_setting_show()
442 dev_warn(&tsdata->client->dev, in edt_ft5x06_setting_show()
444 dattr->attr.name, val, *field); in edt_ft5x06_setting_show()
450 mutex_unlock(&tsdata->mutex); in edt_ft5x06_setting_show()
462 u8 *field = (u8 *)tsdata + attr->field_offset; in edt_ft5x06_setting_store()
467 mutex_lock(&tsdata->mutex); in edt_ft5x06_setting_store()
469 if (tsdata->factory_mode) { in edt_ft5x06_setting_store()
470 error = -EIO; in edt_ft5x06_setting_store()
478 if (val < attr->limit_low || val > attr->limit_high) { in edt_ft5x06_setting_store()
479 error = -ERANGE; in edt_ft5x06_setting_store()
483 switch (tsdata->version) { in edt_ft5x06_setting_store()
485 addr = attr->addr_m06; in edt_ft5x06_setting_store()
491 addr = attr->addr_m09; in edt_ft5x06_setting_store()
495 addr = attr->addr_ev; in edt_ft5x06_setting_store()
499 error = -ENODEV; in edt_ft5x06_setting_store()
506 dev_err(&tsdata->client->dev, in edt_ft5x06_setting_store()
508 dattr->attr.name, error); in edt_ft5x06_setting_store()
515 mutex_unlock(&tsdata->mutex); in edt_ft5x06_setting_store()
519 /* m06, m09: range 0-31, m12: range 0-5 */
522 /* m06, m09: range 0-31, m12: range 0-16 */
525 /* m06, m09, m12: no supported, ev_ft: range 0-80 */
528 /* m06, m09, m12: no supported, ev_ft: range 0-80 */
544 return sysfs_emit(buf, "%s\n", tsdata->name); in model_show()
555 return sysfs_emit(buf, "%s\n", tsdata->fw_version); in fw_version_show()
567 return sysfs_emit(buf, "%d\n", tsdata->header_errors); in header_errors_show()
579 return sysfs_emit(buf, "%d\n", tsdata->crc_errors); in crc_errors_show()
604 struct edt_reg_addr *reg_addr = &tsdata->reg_addr; in edt_ft5x06_restore_reg_parameters()
606 edt_ft5x06_register_write(tsdata, reg_addr->reg_threshold, in edt_ft5x06_restore_reg_parameters()
607 tsdata->threshold); in edt_ft5x06_restore_reg_parameters()
608 edt_ft5x06_register_write(tsdata, reg_addr->reg_gain, in edt_ft5x06_restore_reg_parameters()
609 tsdata->gain); in edt_ft5x06_restore_reg_parameters()
610 if (reg_addr->reg_offset != NO_REGISTER) in edt_ft5x06_restore_reg_parameters()
611 edt_ft5x06_register_write(tsdata, reg_addr->reg_offset, in edt_ft5x06_restore_reg_parameters()
612 tsdata->offset); in edt_ft5x06_restore_reg_parameters()
613 if (reg_addr->reg_offset_x != NO_REGISTER) in edt_ft5x06_restore_reg_parameters()
614 edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_x, in edt_ft5x06_restore_reg_parameters()
615 tsdata->offset_x); in edt_ft5x06_restore_reg_parameters()
616 if (reg_addr->reg_offset_y != NO_REGISTER) in edt_ft5x06_restore_reg_parameters()
617 edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_y, in edt_ft5x06_restore_reg_parameters()
618 tsdata->offset_y); in edt_ft5x06_restore_reg_parameters()
619 if (reg_addr->reg_report_rate != NO_REGISTER) in edt_ft5x06_restore_reg_parameters()
620 edt_ft5x06_register_write(tsdata, reg_addr->reg_report_rate, in edt_ft5x06_restore_reg_parameters()
621 tsdata->report_rate); in edt_ft5x06_restore_reg_parameters()
628 struct i2c_client *client = tsdata->client; in edt_ft5x06_factory_mode()
633 if (tsdata->version != EDT_M06) { in edt_ft5x06_factory_mode()
634 dev_err(&client->dev, in edt_ft5x06_factory_mode()
635 "No factory mode support for non-M06 devices\n"); in edt_ft5x06_factory_mode()
636 return -EINVAL; in edt_ft5x06_factory_mode()
639 disable_irq(client->irq); in edt_ft5x06_factory_mode()
641 if (!tsdata->raw_buffer) { in edt_ft5x06_factory_mode()
642 tsdata->raw_bufsize = tsdata->num_x * tsdata->num_y * in edt_ft5x06_factory_mode()
644 tsdata->raw_buffer = kzalloc(tsdata->raw_bufsize, GFP_KERNEL); in edt_ft5x06_factory_mode()
645 if (!tsdata->raw_buffer) { in edt_ft5x06_factory_mode()
646 error = -ENOMEM; in edt_ft5x06_factory_mode()
654 dev_err(&client->dev, in edt_ft5x06_factory_mode()
659 tsdata->factory_mode = true; in edt_ft5x06_factory_mode()
666 } while (--retries > 0); in edt_ft5x06_factory_mode()
669 dev_err(&client->dev, "not in factory mode after %dms.\n", in edt_ft5x06_factory_mode()
671 error = -EIO; in edt_ft5x06_factory_mode()
678 kfree(tsdata->raw_buffer); in edt_ft5x06_factory_mode()
679 tsdata->raw_buffer = NULL; in edt_ft5x06_factory_mode()
680 tsdata->factory_mode = false; in edt_ft5x06_factory_mode()
681 enable_irq(client->irq); in edt_ft5x06_factory_mode()
688 struct i2c_client *client = tsdata->client; in edt_ft5x06_work_mode()
696 dev_err(&client->dev, in edt_ft5x06_work_mode()
701 tsdata->factory_mode = false; in edt_ft5x06_work_mode()
709 } while (--retries > 0); in edt_ft5x06_work_mode()
712 dev_err(&client->dev, "not in work mode after %dms.\n", in edt_ft5x06_work_mode()
714 tsdata->factory_mode = true; in edt_ft5x06_work_mode()
715 return -EIO; in edt_ft5x06_work_mode()
718 kfree(tsdata->raw_buffer); in edt_ft5x06_work_mode()
719 tsdata->raw_buffer = NULL; in edt_ft5x06_work_mode()
722 enable_irq(client->irq); in edt_ft5x06_work_mode()
731 *mode = tsdata->factory_mode; in edt_ft5x06_debugfs_mode_get()
742 return -ERANGE; in edt_ft5x06_debugfs_mode_set()
744 mutex_lock(&tsdata->mutex); in edt_ft5x06_debugfs_mode_set()
746 if (mode != tsdata->factory_mode) { in edt_ft5x06_debugfs_mode_set()
751 mutex_unlock(&tsdata->mutex); in edt_ft5x06_debugfs_mode_set()
762 struct edt_ft5x06_ts_data *tsdata = file->private_data; in edt_ft5x06_debugfs_raw_data_read()
763 struct i2c_client *client = tsdata->client; in edt_ft5x06_debugfs_raw_data_read()
771 if (*off < 0 || *off >= tsdata->raw_bufsize) in edt_ft5x06_debugfs_raw_data_read()
774 mutex_lock(&tsdata->mutex); in edt_ft5x06_debugfs_raw_data_read()
776 if (!tsdata->factory_mode || !tsdata->raw_buffer) { in edt_ft5x06_debugfs_raw_data_read()
777 error = -EIO; in edt_ft5x06_debugfs_raw_data_read()
783 dev_dbg(&client->dev, in edt_ft5x06_debugfs_raw_data_read()
793 } while (--retries > 0); in edt_ft5x06_debugfs_raw_data_read()
797 dev_dbg(&client->dev, in edt_ft5x06_debugfs_raw_data_read()
803 dev_dbg(&client->dev, in edt_ft5x06_debugfs_raw_data_read()
805 error = -ETIMEDOUT; in edt_ft5x06_debugfs_raw_data_read()
809 rdbuf = tsdata->raw_buffer; in edt_ft5x06_debugfs_raw_data_read()
810 colbytes = tsdata->num_y * sizeof(u16); in edt_ft5x06_debugfs_raw_data_read()
814 for (i = 0; i < tsdata->num_x; i++) { in edt_ft5x06_debugfs_raw_data_read()
816 error = edt_ft5x06_ts_readwrite(tsdata->client, in edt_ft5x06_debugfs_raw_data_read()
825 read = min_t(size_t, count, tsdata->raw_bufsize - *off); in edt_ft5x06_debugfs_raw_data_read()
826 if (copy_to_user(buf, tsdata->raw_buffer + *off, read)) { in edt_ft5x06_debugfs_raw_data_read()
827 error = -EFAULT; in edt_ft5x06_debugfs_raw_data_read()
833 mutex_unlock(&tsdata->mutex); in edt_ft5x06_debugfs_raw_data_read()
845 tsdata->debug_dir = debugfs_create_dir(debugfs_name, NULL); in edt_ft5x06_ts_prepare_debugfs()
847 debugfs_create_u16("num_x", S_IRUSR, tsdata->debug_dir, &tsdata->num_x); in edt_ft5x06_ts_prepare_debugfs()
848 debugfs_create_u16("num_y", S_IRUSR, tsdata->debug_dir, &tsdata->num_y); in edt_ft5x06_ts_prepare_debugfs()
851 tsdata->debug_dir, tsdata, &debugfs_mode_fops); in edt_ft5x06_ts_prepare_debugfs()
853 tsdata->debug_dir, tsdata, &debugfs_raw_data_fops); in edt_ft5x06_ts_prepare_debugfs()
858 debugfs_remove_recursive(tsdata->debug_dir); in edt_ft5x06_ts_teardown_debugfs()
859 kfree(tsdata->raw_buffer); in edt_ft5x06_ts_teardown_debugfs()
866 return -ENOSYS; in edt_ft5x06_factory_mode()
886 char *model_name = tsdata->name; in edt_ft5x06_ts_identify()
887 char *fw_version = tsdata->fw_version; in edt_ft5x06_ts_identify()
895 EDT_NAME_LEN - 1, rdbuf); in edt_ft5x06_ts_identify()
904 tsdata->version = EDT_M06; in edt_ft5x06_ts_identify()
907 rdbuf[EDT_NAME_LEN - 1] = '\0'; in edt_ft5x06_ts_identify()
908 if (rdbuf[EDT_NAME_LEN - 2] == '$') in edt_ft5x06_ts_identify()
909 rdbuf[EDT_NAME_LEN - 2] = '\0'; in edt_ft5x06_ts_identify()
918 tsdata->version = EDT_M12; in edt_ft5x06_ts_identify()
921 rdbuf[EDT_NAME_LEN - 2] = '\0'; in edt_ft5x06_ts_identify()
922 if (rdbuf[EDT_NAME_LEN - 3] == '$') in edt_ft5x06_ts_identify()
923 rdbuf[EDT_NAME_LEN - 3] = '\0'; in edt_ft5x06_ts_identify()
941 tsdata->version = GENERIC_FT; in edt_ft5x06_ts_identify()
966 tsdata->version = EDT_M09; in edt_ft5x06_ts_identify()
971 tsdata->version = EDT_M09; in edt_ft5x06_ts_identify()
979 tsdata->version = EV_FT; in edt_ft5x06_ts_identify()
986 "EVERVISION-FT5726NEi"); in edt_ft5x06_ts_identify()
1002 struct edt_reg_addr *reg_addr = &tsdata->reg_addr; in edt_ft5x06_ts_get_defaults()
1008 edt_ft5x06_register_write(tsdata, reg_addr->reg_threshold, val); in edt_ft5x06_ts_get_defaults()
1009 tsdata->threshold = val; in edt_ft5x06_ts_get_defaults()
1014 edt_ft5x06_register_write(tsdata, reg_addr->reg_gain, val); in edt_ft5x06_ts_get_defaults()
1015 tsdata->gain = val; in edt_ft5x06_ts_get_defaults()
1020 if (reg_addr->reg_offset != NO_REGISTER) in edt_ft5x06_ts_get_defaults()
1022 reg_addr->reg_offset, val); in edt_ft5x06_ts_get_defaults()
1023 tsdata->offset = val; in edt_ft5x06_ts_get_defaults()
1026 error = device_property_read_u32(dev, "offset-x", &val); in edt_ft5x06_ts_get_defaults()
1028 if (reg_addr->reg_offset_x != NO_REGISTER) in edt_ft5x06_ts_get_defaults()
1030 reg_addr->reg_offset_x, val); in edt_ft5x06_ts_get_defaults()
1031 tsdata->offset_x = val; in edt_ft5x06_ts_get_defaults()
1034 error = device_property_read_u32(dev, "offset-y", &val); in edt_ft5x06_ts_get_defaults()
1036 if (reg_addr->reg_offset_y != NO_REGISTER) in edt_ft5x06_ts_get_defaults()
1038 reg_addr->reg_offset_y, val); in edt_ft5x06_ts_get_defaults()
1039 tsdata->offset_y = val; in edt_ft5x06_ts_get_defaults()
1045 struct edt_reg_addr *reg_addr = &tsdata->reg_addr; in edt_ft5x06_ts_get_parameters()
1047 tsdata->threshold = edt_ft5x06_register_read(tsdata, in edt_ft5x06_ts_get_parameters()
1048 reg_addr->reg_threshold); in edt_ft5x06_ts_get_parameters()
1049 tsdata->gain = edt_ft5x06_register_read(tsdata, reg_addr->reg_gain); in edt_ft5x06_ts_get_parameters()
1050 if (reg_addr->reg_offset != NO_REGISTER) in edt_ft5x06_ts_get_parameters()
1051 tsdata->offset = in edt_ft5x06_ts_get_parameters()
1052 edt_ft5x06_register_read(tsdata, reg_addr->reg_offset); in edt_ft5x06_ts_get_parameters()
1053 if (reg_addr->reg_offset_x != NO_REGISTER) in edt_ft5x06_ts_get_parameters()
1054 tsdata->offset_x = edt_ft5x06_register_read(tsdata, in edt_ft5x06_ts_get_parameters()
1055 reg_addr->reg_offset_x); in edt_ft5x06_ts_get_parameters()
1056 if (reg_addr->reg_offset_y != NO_REGISTER) in edt_ft5x06_ts_get_parameters()
1057 tsdata->offset_y = edt_ft5x06_register_read(tsdata, in edt_ft5x06_ts_get_parameters()
1058 reg_addr->reg_offset_y); in edt_ft5x06_ts_get_parameters()
1059 if (reg_addr->reg_report_rate != NO_REGISTER) in edt_ft5x06_ts_get_parameters()
1060 tsdata->report_rate = edt_ft5x06_register_read(tsdata, in edt_ft5x06_ts_get_parameters()
1061 reg_addr->reg_report_rate); in edt_ft5x06_ts_get_parameters()
1062 tsdata->num_x = EDT_DEFAULT_NUM_X; in edt_ft5x06_ts_get_parameters()
1063 if (reg_addr->reg_num_x != NO_REGISTER) in edt_ft5x06_ts_get_parameters()
1064 tsdata->num_x = edt_ft5x06_register_read(tsdata, in edt_ft5x06_ts_get_parameters()
1065 reg_addr->reg_num_x); in edt_ft5x06_ts_get_parameters()
1066 tsdata->num_y = EDT_DEFAULT_NUM_Y; in edt_ft5x06_ts_get_parameters()
1067 if (reg_addr->reg_num_y != NO_REGISTER) in edt_ft5x06_ts_get_parameters()
1068 tsdata->num_y = edt_ft5x06_register_read(tsdata, in edt_ft5x06_ts_get_parameters()
1069 reg_addr->reg_num_y); in edt_ft5x06_ts_get_parameters()
1074 struct edt_reg_addr *reg_addr = &tsdata->reg_addr; in edt_ft5x06_ts_set_regs()
1076 switch (tsdata->version) { in edt_ft5x06_ts_set_regs()
1078 reg_addr->reg_threshold = WORK_REGISTER_THRESHOLD; in edt_ft5x06_ts_set_regs()
1079 reg_addr->reg_report_rate = WORK_REGISTER_REPORT_RATE; in edt_ft5x06_ts_set_regs()
1080 reg_addr->reg_gain = WORK_REGISTER_GAIN; in edt_ft5x06_ts_set_regs()
1081 reg_addr->reg_offset = WORK_REGISTER_OFFSET; in edt_ft5x06_ts_set_regs()
1082 reg_addr->reg_offset_x = NO_REGISTER; in edt_ft5x06_ts_set_regs()
1083 reg_addr->reg_offset_y = NO_REGISTER; in edt_ft5x06_ts_set_regs()
1084 reg_addr->reg_num_x = WORK_REGISTER_NUM_X; in edt_ft5x06_ts_set_regs()
1085 reg_addr->reg_num_y = WORK_REGISTER_NUM_Y; in edt_ft5x06_ts_set_regs()
1090 reg_addr->reg_threshold = M09_REGISTER_THRESHOLD; in edt_ft5x06_ts_set_regs()
1091 reg_addr->reg_report_rate = tsdata->version == EDT_M12 ? in edt_ft5x06_ts_set_regs()
1093 reg_addr->reg_gain = M09_REGISTER_GAIN; in edt_ft5x06_ts_set_regs()
1094 reg_addr->reg_offset = M09_REGISTER_OFFSET; in edt_ft5x06_ts_set_regs()
1095 reg_addr->reg_offset_x = NO_REGISTER; in edt_ft5x06_ts_set_regs()
1096 reg_addr->reg_offset_y = NO_REGISTER; in edt_ft5x06_ts_set_regs()
1097 reg_addr->reg_num_x = M09_REGISTER_NUM_X; in edt_ft5x06_ts_set_regs()
1098 reg_addr->reg_num_y = M09_REGISTER_NUM_Y; in edt_ft5x06_ts_set_regs()
1102 reg_addr->reg_threshold = EV_REGISTER_THRESHOLD; in edt_ft5x06_ts_set_regs()
1103 reg_addr->reg_report_rate = NO_REGISTER; in edt_ft5x06_ts_set_regs()
1104 reg_addr->reg_gain = EV_REGISTER_GAIN; in edt_ft5x06_ts_set_regs()
1105 reg_addr->reg_offset = NO_REGISTER; in edt_ft5x06_ts_set_regs()
1106 reg_addr->reg_offset_x = EV_REGISTER_OFFSET_X; in edt_ft5x06_ts_set_regs()
1107 reg_addr->reg_offset_y = EV_REGISTER_OFFSET_Y; in edt_ft5x06_ts_set_regs()
1108 reg_addr->reg_num_x = NO_REGISTER; in edt_ft5x06_ts_set_regs()
1109 reg_addr->reg_num_y = NO_REGISTER; in edt_ft5x06_ts_set_regs()
1114 reg_addr->reg_threshold = M09_REGISTER_THRESHOLD; in edt_ft5x06_ts_set_regs()
1115 reg_addr->reg_report_rate = NO_REGISTER; in edt_ft5x06_ts_set_regs()
1116 reg_addr->reg_gain = M09_REGISTER_GAIN; in edt_ft5x06_ts_set_regs()
1117 reg_addr->reg_offset = M09_REGISTER_OFFSET; in edt_ft5x06_ts_set_regs()
1118 reg_addr->reg_offset_x = NO_REGISTER; in edt_ft5x06_ts_set_regs()
1119 reg_addr->reg_offset_y = NO_REGISTER; in edt_ft5x06_ts_set_regs()
1120 reg_addr->reg_num_x = NO_REGISTER; in edt_ft5x06_ts_set_regs()
1121 reg_addr->reg_num_y = NO_REGISTER; in edt_ft5x06_ts_set_regs()
1130 regulator_disable(data->vcc); in edt_ft5x06_disable_regulators()
1131 regulator_disable(data->iovcc); in edt_ft5x06_disable_regulators()
1145 dev_dbg(&client->dev, "probing for EDT FT5x06 I2C\n"); in edt_ft5x06_ts_probe()
1147 tsdata = devm_kzalloc(&client->dev, sizeof(*tsdata), GFP_KERNEL); in edt_ft5x06_ts_probe()
1149 dev_err(&client->dev, "failed to allocate driver data.\n"); in edt_ft5x06_ts_probe()
1150 return -ENOMEM; in edt_ft5x06_ts_probe()
1153 chip_data = device_get_match_data(&client->dev); in edt_ft5x06_ts_probe()
1155 chip_data = (const struct edt_i2c_chip_data *)id->driver_data; in edt_ft5x06_ts_probe()
1156 if (!chip_data || !chip_data->max_support_points) { in edt_ft5x06_ts_probe()
1157 dev_err(&client->dev, "invalid or missing chip data\n"); in edt_ft5x06_ts_probe()
1158 return -EINVAL; in edt_ft5x06_ts_probe()
1161 tsdata->max_support_points = chip_data->max_support_points; in edt_ft5x06_ts_probe()
1163 tsdata->vcc = devm_regulator_get(&client->dev, "vcc"); in edt_ft5x06_ts_probe()
1164 if (IS_ERR(tsdata->vcc)) { in edt_ft5x06_ts_probe()
1165 error = PTR_ERR(tsdata->vcc); in edt_ft5x06_ts_probe()
1166 if (error != -EPROBE_DEFER) in edt_ft5x06_ts_probe()
1167 dev_err(&client->dev, in edt_ft5x06_ts_probe()
1172 tsdata->iovcc = devm_regulator_get(&client->dev, "iovcc"); in edt_ft5x06_ts_probe()
1173 if (IS_ERR(tsdata->iovcc)) { in edt_ft5x06_ts_probe()
1174 error = PTR_ERR(tsdata->iovcc); in edt_ft5x06_ts_probe()
1175 if (error != -EPROBE_DEFER) in edt_ft5x06_ts_probe()
1176 dev_err(&client->dev, in edt_ft5x06_ts_probe()
1177 "failed to request iovcc regulator: %d\n", error); in edt_ft5x06_ts_probe()
1181 error = regulator_enable(tsdata->iovcc); in edt_ft5x06_ts_probe()
1183 dev_err(&client->dev, "failed to enable iovcc: %d\n", error); in edt_ft5x06_ts_probe()
1187 /* Delay enabling VCC for > 10us (T_ivd) after IOVCC */ in edt_ft5x06_ts_probe()
1190 error = regulator_enable(tsdata->vcc); in edt_ft5x06_ts_probe()
1192 dev_err(&client->dev, "failed to enable vcc: %d\n", error); in edt_ft5x06_ts_probe()
1193 regulator_disable(tsdata->iovcc); in edt_ft5x06_ts_probe()
1197 error = devm_add_action_or_reset(&client->dev, in edt_ft5x06_ts_probe()
1203 tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev, in edt_ft5x06_ts_probe()
1205 if (IS_ERR(tsdata->reset_gpio)) { in edt_ft5x06_ts_probe()
1206 error = PTR_ERR(tsdata->reset_gpio); in edt_ft5x06_ts_probe()
1207 dev_err(&client->dev, in edt_ft5x06_ts_probe()
1212 tsdata->wake_gpio = devm_gpiod_get_optional(&client->dev, in edt_ft5x06_ts_probe()
1214 if (IS_ERR(tsdata->wake_gpio)) { in edt_ft5x06_ts_probe()
1215 error = PTR_ERR(tsdata->wake_gpio); in edt_ft5x06_ts_probe()
1216 dev_err(&client->dev, in edt_ft5x06_ts_probe()
1222 * Check which sleep modes we can support. Power-off requieres the in edt_ft5x06_ts_probe()
1223 * reset-pin to ensure correct power-down/power-up behaviour. Start with in edt_ft5x06_ts_probe()
1227 if (tsdata->reset_gpio) in edt_ft5x06_ts_probe()
1228 tsdata->suspend_mode = EDT_PMODE_POWEROFF; in edt_ft5x06_ts_probe()
1229 else if (tsdata->wake_gpio) in edt_ft5x06_ts_probe()
1230 tsdata->suspend_mode = EDT_PMODE_HIBERNATE; in edt_ft5x06_ts_probe()
1232 tsdata->suspend_mode = EDT_PMODE_NOT_SUPPORTED; in edt_ft5x06_ts_probe()
1234 if (tsdata->wake_gpio) { in edt_ft5x06_ts_probe()
1236 gpiod_set_value_cansleep(tsdata->wake_gpio, 1); in edt_ft5x06_ts_probe()
1239 if (tsdata->reset_gpio) { in edt_ft5x06_ts_probe()
1241 gpiod_set_value_cansleep(tsdata->reset_gpio, 0); in edt_ft5x06_ts_probe()
1245 input = devm_input_allocate_device(&client->dev); in edt_ft5x06_ts_probe()
1247 dev_err(&client->dev, "failed to allocate input device.\n"); in edt_ft5x06_ts_probe()
1248 return -ENOMEM; in edt_ft5x06_ts_probe()
1251 mutex_init(&tsdata->mutex); in edt_ft5x06_ts_probe()
1252 tsdata->client = client; in edt_ft5x06_ts_probe()
1253 tsdata->input = input; in edt_ft5x06_ts_probe()
1254 tsdata->factory_mode = false; in edt_ft5x06_ts_probe()
1258 dev_err(&client->dev, "touchscreen probe failed\n"); in edt_ft5x06_ts_probe()
1266 edt_ft5x06_ts_readwrite(tsdata->client, 2, buf, 2, buf); in edt_ft5x06_ts_probe()
1269 edt_ft5x06_ts_get_defaults(&client->dev, tsdata); in edt_ft5x06_ts_probe()
1272 if (tsdata->reg_addr.reg_report_rate != NO_REGISTER && in edt_ft5x06_ts_probe()
1273 !device_property_read_u32(&client->dev, in edt_ft5x06_ts_probe()
1274 "report-rate-hz", &report_rate)) { in edt_ft5x06_ts_probe()
1275 if (tsdata->version == EDT_M06) in edt_ft5x06_ts_probe()
1276 tsdata->report_rate = clamp_val(report_rate, 30, 140); in edt_ft5x06_ts_probe()
1278 tsdata->report_rate = clamp_val(report_rate, 1, 255); in edt_ft5x06_ts_probe()
1280 if (report_rate != tsdata->report_rate) in edt_ft5x06_ts_probe()
1281 dev_warn(&client->dev, in edt_ft5x06_ts_probe()
1282 "report-rate %dHz is unsupported, use %dHz\n", in edt_ft5x06_ts_probe()
1283 report_rate, tsdata->report_rate); in edt_ft5x06_ts_probe()
1285 if (tsdata->version == EDT_M06) in edt_ft5x06_ts_probe()
1286 tsdata->report_rate /= 10; in edt_ft5x06_ts_probe()
1289 tsdata->reg_addr.reg_report_rate, in edt_ft5x06_ts_probe()
1290 tsdata->report_rate); in edt_ft5x06_ts_probe()
1293 dev_dbg(&client->dev, in edt_ft5x06_ts_probe()
1295 tsdata->name, tsdata->fw_version, tsdata->num_x, tsdata->num_y); in edt_ft5x06_ts_probe()
1297 input->name = tsdata->name; in edt_ft5x06_ts_probe()
1298 input->id.bustype = BUS_I2C; in edt_ft5x06_ts_probe()
1299 input->dev.parent = &client->dev; in edt_ft5x06_ts_probe()
1302 0, tsdata->num_x * 64 - 1, 0, 0); in edt_ft5x06_ts_probe()
1304 0, tsdata->num_y * 64 - 1, 0, 0); in edt_ft5x06_ts_probe()
1306 touchscreen_parse_properties(input, true, &tsdata->prop); in edt_ft5x06_ts_probe()
1308 error = input_mt_init_slots(input, tsdata->max_support_points, in edt_ft5x06_ts_probe()
1311 dev_err(&client->dev, "Unable to init MT slots.\n"); in edt_ft5x06_ts_probe()
1317 irq_flags = irq_get_trigger_type(client->irq); in edt_ft5x06_ts_probe()
1322 error = devm_request_threaded_irq(&client->dev, client->irq, in edt_ft5x06_ts_probe()
1324 client->name, tsdata); in edt_ft5x06_ts_probe()
1326 dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); in edt_ft5x06_ts_probe()
1330 error = devm_device_add_group(&client->dev, &edt_ft5x06_attr_group); in edt_ft5x06_ts_probe()
1338 edt_ft5x06_ts_prepare_debugfs(tsdata, dev_driver_string(&client->dev)); in edt_ft5x06_ts_probe()
1340 dev_dbg(&client->dev, in edt_ft5x06_ts_probe()
1342 client->irq, in edt_ft5x06_ts_probe()
1343 tsdata->wake_gpio ? desc_to_gpio(tsdata->wake_gpio) : -1, in edt_ft5x06_ts_probe()
1344 tsdata->reset_gpio ? desc_to_gpio(tsdata->reset_gpio) : -1); in edt_ft5x06_ts_probe()
1360 struct gpio_desc *reset_gpio = tsdata->reset_gpio; in edt_ft5x06_ts_suspend()
1366 if (tsdata->suspend_mode == EDT_PMODE_NOT_SUPPORTED) in edt_ft5x06_ts_suspend()
1375 if (tsdata->suspend_mode == EDT_PMODE_HIBERNATE) in edt_ft5x06_ts_suspend()
1379 * Power-off according the datasheet. Cut the power may leaf the irq in edt_ft5x06_ts_suspend()
1384 disable_irq(tsdata->client->irq); in edt_ft5x06_ts_suspend()
1389 ret = regulator_disable(tsdata->vcc); in edt_ft5x06_ts_suspend()
1392 ret = regulator_disable(tsdata->iovcc); in edt_ft5x06_ts_suspend()
1394 dev_warn(dev, "Failed to disable iovcc\n"); in edt_ft5x06_ts_suspend()
1408 if (tsdata->suspend_mode == EDT_PMODE_NOT_SUPPORTED) in edt_ft5x06_ts_resume()
1411 if (tsdata->suspend_mode == EDT_PMODE_POWEROFF) { in edt_ft5x06_ts_resume()
1412 struct gpio_desc *reset_gpio = tsdata->reset_gpio; in edt_ft5x06_ts_resume()
1418 * 300ms in case it was a real supply and the power was cutted in edt_ft5x06_ts_resume()
1425 ret = regulator_enable(tsdata->iovcc); in edt_ft5x06_ts_resume()
1427 dev_err(dev, "Failed to enable iovcc\n"); in edt_ft5x06_ts_resume()
1431 /* Delay enabling VCC for > 10us (T_ivd) after IOVCC */ in edt_ft5x06_ts_resume()
1434 ret = regulator_enable(tsdata->vcc); in edt_ft5x06_ts_resume()
1437 regulator_disable(tsdata->iovcc); in edt_ft5x06_ts_resume()
1446 enable_irq(tsdata->client->irq); in edt_ft5x06_ts_resume()
1448 if (tsdata->factory_mode) in edt_ft5x06_ts_resume()
1451 struct gpio_desc *wake_gpio = tsdata->wake_gpio; in edt_ft5x06_ts_resume()
1478 { .name = "edt-ft5x06", .driver_data = (long)&edt_ft5x06_data },
1479 { .name = "edt-ft5506", .driver_data = (long)&edt_ft5506_data },
1480 { .name = "ev-ft5726", .driver_data = (long)&edt_ft5506_data },
1481 /* Note no edt- prefix for compatibility with the ft6236.c driver */
1488 { .compatible = "edt,edt-ft5206", .data = &edt_ft5x06_data },
1489 { .compatible = "edt,edt-ft5306", .data = &edt_ft5x06_data },
1490 { .compatible = "edt,edt-ft5406", .data = &edt_ft5x06_data },
1491 { .compatible = "edt,edt-ft5506", .data = &edt_ft5506_data },
1492 { .compatible = "evervision,ev-ft5726", .data = &edt_ft5506_data },