Lines Matching +full:deep +full:- +full:touch

1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Copyright (C) 2011-2014 Atmel Corporation
30 #include <media/v4l2-device.h>
31 #include <media/v4l2-ioctl.h>
32 #include <media/videobuf2-v4l2.h>
33 #include <media/videobuf2-vmalloc.h>
34 #include <dt-bindings/input/atmel-maxtouch.h>
161 /* T100 Multiple Touch Touchscreen */
367 return obj->size_minus_one + 1; in mxt_obj_size()
372 return obj->instances_minus_one + 1; in mxt_obj_instances()
413 dev_dbg(&data->client->dev, "message: %*ph\n", in mxt_dump_message()
414 data->T5_msg_size, message); in mxt_dump_message()
421 struct device *dev = &data->client->dev; in mxt_wait_for_completion()
430 return -ETIMEDOUT; in mxt_wait_for_completion()
441 msg.addr = data->bootloader_addr; in mxt_bootloader_read()
442 msg.flags = data->client->flags & I2C_M_TEN; in mxt_bootloader_read()
447 ret = i2c_transfer(data->client->adapter, &msg, 1); in mxt_bootloader_read()
451 ret = ret < 0 ? ret : -EIO; in mxt_bootloader_read()
452 dev_err(&data->client->dev, "%s: i2c recv failed (%d)\n", in mxt_bootloader_read()
465 msg.addr = data->bootloader_addr; in mxt_bootloader_write()
466 msg.flags = data->client->flags & I2C_M_TEN; in mxt_bootloader_write()
470 ret = i2c_transfer(data->client->adapter, &msg, 1); in mxt_bootloader_write()
474 ret = ret < 0 ? ret : -EIO; in mxt_bootloader_write()
475 dev_err(&data->client->dev, "%s: i2c send failed (%d)\n", in mxt_bootloader_write()
484 u8 appmode = data->client->addr; in mxt_lookup_bootloader_address()
486 u8 family_id = data->info ? data->info->family_id : 0; in mxt_lookup_bootloader_address()
493 bootloader = appmode - 0x24; in mxt_lookup_bootloader_address()
501 bootloader = appmode - 0x26; in mxt_lookup_bootloader_address()
505 dev_err(&data->client->dev, in mxt_lookup_bootloader_address()
508 return -EINVAL; in mxt_lookup_bootloader_address()
511 data->bootloader_addr = bootloader; in mxt_lookup_bootloader_address()
517 struct device *dev = &data->client->dev; in mxt_probe_bootloader()
541 struct device *dev = &data->client->dev; in mxt_get_bootloader_version()
563 struct device *dev = &data->client->dev; in mxt_check_bootloader()
575 ret = mxt_wait_for_completion(data, &data->bl_completion, in mxt_check_bootloader()
579 * TODO: handle -ERESTARTSYS better by terminating in mxt_check_bootloader()
607 return -EINVAL; in mxt_check_bootloader()
611 return -EINVAL; in mxt_check_bootloader()
617 return -EINVAL; in mxt_check_bootloader()
643 switch (data->wakeup_method) { in mxt_wakeup_toggle()
653 gpiod_set_value(data->wake_gpio, wake_up); in mxt_wakeup_toggle()
661 dev_dbg(&client->dev, "waking up controller\n"); in mxt_wakeup_toggle()
681 xfer[0].addr = client->addr; in __mxt_read_reg()
687 xfer[1].addr = client->addr; in __mxt_read_reg()
693 ret = i2c_transfer(client->adapter, xfer, 2); in __mxt_read_reg()
701 ret = -EIO; in __mxt_read_reg()
702 dev_err(&client->dev, "%s: i2c transfer failed (%d)\n", in __mxt_read_reg()
720 return -ENOMEM; in __mxt_write_reg()
735 ret = -EIO; in __mxt_write_reg()
736 dev_err(&client->dev, "%s: i2c send failed (%d)\n", in __mxt_write_reg()
755 for (i = 0; i < data->info->object_num; i++) { in mxt_get_object()
756 object = data->object_table + i; in mxt_get_object()
757 if (object->type == type) in mxt_get_object()
761 dev_warn(&data->client->dev, "Invalid object type T%u\n", type); in mxt_get_object()
767 struct device *dev = &data->client->dev; in mxt_proc_t6_messages()
771 if (crc != data->config_crc) { in mxt_proc_t6_messages()
772 data->config_crc = crc; in mxt_proc_t6_messages()
776 complete(&data->crc_completion); in mxt_proc_t6_messages()
780 complete(&data->reset_completion); in mxt_proc_t6_messages()
783 if (status != data->t6_status) in mxt_proc_t6_messages()
795 data->t6_status = status; in mxt_proc_t6_messages()
806 return -EINVAL; in mxt_write_object()
808 reg = object->start_address; in mxt_write_object()
809 return mxt_write_reg(data->client, reg + offset, val); in mxt_write_object()
814 struct input_dev *input = data->input_dev; in mxt_input_button()
817 for (i = 0; i < data->t19_num_keys; i++) { in mxt_input_button()
818 if (data->t19_keymap[i] == KEY_RESERVED) in mxt_input_button()
821 /* Active-low switch */ in mxt_input_button()
822 input_report_key(input, data->t19_keymap[i], in mxt_input_button()
829 input_mt_report_pointer_emulation(data->input_dev, in mxt_input_sync()
830 data->t19_num_keys); in mxt_input_sync()
831 input_sync(data->input_dev); in mxt_input_sync()
836 struct device *dev = &data->client->dev; in mxt_proc_t9_message()
837 struct input_dev *input_dev = data->input_dev; in mxt_proc_t9_message()
845 id = message[0] - data->T9_reportid_min; in mxt_proc_t9_message()
851 if (data->max_x < 1024) in mxt_proc_t9_message()
853 if (data->max_y < 1024) in mxt_proc_t9_message()
885 /* if active, pressure must be non-zero */ in mxt_proc_t9_message()
889 /* Touch active */ in mxt_proc_t9_message()
896 /* Touch no longer active, close out slot */ in mxt_proc_t9_message()
900 data->update_input = true; in mxt_proc_t9_message()
905 struct input_dev *input_dev = data->input_dev; in mxt_proc_t15_messages()
909 for (key = 0; key < data->t15_num_keys; key++) in mxt_proc_t15_messages()
910 input_report_key(input_dev, data->t15_keymap[key], in mxt_proc_t15_messages()
913 data->update_input = true; in mxt_proc_t15_messages()
923 struct device *dev = &data->client->dev; in mxt_proc_t100_message()
924 struct input_dev *input_dev = data->input_dev; in mxt_proc_t100_message()
936 id = message[0] - data->T100_reportid_min - 2; in mxt_proc_t100_message()
954 if (data->t100_aux_vect) in mxt_proc_t100_message()
955 orientation = message[data->t100_aux_vect]; in mxt_proc_t100_message()
964 if (data->t100_aux_area) in mxt_proc_t100_message()
965 major = message[data->t100_aux_area]; in mxt_proc_t100_message()
967 if (data->t100_aux_ampl) in mxt_proc_t100_message()
968 pressure = message[data->t100_aux_ampl]; in mxt_proc_t100_message()
970 if (data->t100_aux_vect) in mxt_proc_t100_message()
971 orientation = message[data->t100_aux_vect]; in mxt_proc_t100_message()
984 if (data->t100_aux_ampl) in mxt_proc_t100_message()
985 pressure = message[data->t100_aux_ampl]; in mxt_proc_t100_message()
990 /* Ignore suppressed touch */ in mxt_proc_t100_message()
1000 * Values reported should be non-zero if tool is touching the in mxt_proc_t100_message()
1026 data->update_input = true; in mxt_proc_t100_message()
1036 if (report_id == data->T6_reportid) { in mxt_proc_message()
1038 } else if (!data->input_dev) { in mxt_proc_message()
1044 } else if (report_id >= data->T9_reportid_min && in mxt_proc_message()
1045 report_id <= data->T9_reportid_max) { in mxt_proc_message()
1047 } else if (report_id >= data->T15_reportid_min && in mxt_proc_message()
1048 report_id <= data->T15_reportid_max) { in mxt_proc_message()
1050 } else if (report_id >= data->T97_reportid_min && in mxt_proc_message()
1051 report_id <= data->T97_reportid_max) { in mxt_proc_message()
1053 } else if (report_id >= data->T100_reportid_min && in mxt_proc_message()
1054 report_id <= data->T100_reportid_max) { in mxt_proc_message()
1056 } else if (report_id == data->T19_reportid) { in mxt_proc_message()
1058 data->update_input = true; in mxt_proc_message()
1068 struct device *dev = &data->client->dev; in mxt_read_and_process_messages()
1074 if (count > data->max_reportid) in mxt_read_and_process_messages()
1075 return -EINVAL; in mxt_read_and_process_messages()
1078 ret = __mxt_read_reg(data->client, data->T5_address, in mxt_read_and_process_messages()
1079 data->T5_msg_size * count, data->msg_buf); in mxt_read_and_process_messages()
1087 data->msg_buf + data->T5_msg_size * i); in mxt_read_and_process_messages()
1099 struct device *dev = &data->client->dev; in mxt_process_messages_t44()
1104 ret = __mxt_read_reg(data->client, data->T44_address, in mxt_process_messages_t44()
1105 data->T5_msg_size + 1, data->msg_buf); in mxt_process_messages_t44()
1111 count = data->msg_buf[0]; in mxt_process_messages_t44()
1120 if (count > data->max_reportid) { in mxt_process_messages_t44()
1122 count = data->max_reportid; in mxt_process_messages_t44()
1126 ret = mxt_proc_message(data, data->msg_buf + 1); in mxt_process_messages_t44()
1132 num_left = count - 1; in mxt_process_messages_t44()
1144 if (data->update_input) { in mxt_process_messages_t44()
1146 data->update_input = false; in mxt_process_messages_t44()
1154 struct device *dev = &data->client->dev; in mxt_process_messages_until_invalid()
1158 count = data->max_reportid; in mxt_process_messages_until_invalid()
1165 } while (--tries); in mxt_process_messages_until_invalid()
1167 if (data->update_input) { in mxt_process_messages_until_invalid()
1169 data->update_input = false; in mxt_process_messages_until_invalid()
1173 return -EBUSY; in mxt_process_messages_until_invalid()
1179 u8 count = data->last_message_count; in mxt_process_messages()
1181 if (count < 1 || count > data->max_reportid) in mxt_process_messages()
1202 } while (total_handled < data->num_touchids); in mxt_process_messages()
1205 data->last_message_count = total_handled; in mxt_process_messages()
1207 if (data->update_input) { in mxt_process_messages()
1209 data->update_input = false; in mxt_process_messages()
1219 if (data->in_bootloader) { in mxt_interrupt()
1221 complete(&data->bl_completion); in mxt_interrupt()
1225 if (!data->object_table) in mxt_interrupt()
1228 if (data->T44_address) { in mxt_interrupt()
1243 reg = data->T6_address + cmd_offset; in mxt_t6_command()
1245 ret = mxt_write_reg(data->client, reg, value); in mxt_t6_command()
1254 ret = __mxt_read_reg(data->client, reg, 1, &command_register); in mxt_t6_command()
1260 dev_err(&data->client->dev, "Command failed!\n"); in mxt_t6_command()
1261 return -EIO; in mxt_t6_command()
1271 enable_irq(data->irq); in mxt_acquire_irq()
1273 if (data->use_retrigen_workaround) { in mxt_acquire_irq()
1284 struct device *dev = &data->client->dev; in mxt_soft_reset()
1289 disable_irq(data->irq); in mxt_soft_reset()
1291 reinit_completion(&data->reset_completion); in mxt_soft_reset()
1302 ret = mxt_wait_for_completion(data, &data->reset_completion, in mxt_soft_reset()
1316 data->config_crc = 0; in mxt_update_crc()
1317 reinit_completion(&data->crc_completion); in mxt_update_crc()
1325 mxt_wait_for_completion(data, &data->crc_completion, MXT_CRC_TIMEOUT); in mxt_update_crc()
1347 u8 *last_val = base + end_off - 1; in mxt_calculate_crc()
1350 return -EINVAL; in mxt_calculate_crc()
1361 /* Mask to 24-bit */ in mxt_calculate_crc()
1369 struct i2c_client *client = data->client; in mxt_check_retrigen()
1374 data->use_retrigen_workaround = false; in mxt_check_retrigen()
1376 irqd = irq_get_irq_data(data->irq); in mxt_check_retrigen()
1378 return -EINVAL; in mxt_check_retrigen()
1383 if (data->T18_address) { in mxt_check_retrigen()
1385 data->T18_address + MXT_COMMS_CTRL, in mxt_check_retrigen()
1394 dev_warn(&client->dev, "Enabling RETRIGEN workaround\n"); in mxt_check_retrigen()
1395 data->use_retrigen_workaround = true; in mxt_check_retrigen()
1401 struct device *dev = &data->client->dev; in mxt_prepare_cfg_mem()
1410 while (cfg->raw_pos < cfg->raw_size) { in mxt_prepare_cfg_mem()
1412 ret = sscanf(cfg->raw + cfg->raw_pos, "%x %x %x%n", in mxt_prepare_cfg_mem()
1419 return -EINVAL; in mxt_prepare_cfg_mem()
1421 cfg->raw_pos += offset; in mxt_prepare_cfg_mem()
1427 ret = sscanf(cfg->raw + cfg->raw_pos, "%hhx%n", in mxt_prepare_cfg_mem()
1432 return -EINVAL; in mxt_prepare_cfg_mem()
1434 cfg->raw_pos += offset; in mxt_prepare_cfg_mem()
1443 * or the file is corrupt or hand-edited. in mxt_prepare_cfg_mem()
1446 size - mxt_obj_size(object), type); in mxt_prepare_cfg_mem()
1451 * to zero these bytes - previous behaviour will be in mxt_prepare_cfg_mem()
1454 * updated. We warn here but do nothing else - the in mxt_prepare_cfg_mem()
1458 mxt_obj_size(object) - size, type); in mxt_prepare_cfg_mem()
1463 return -EINVAL; in mxt_prepare_cfg_mem()
1466 reg = object->start_address + mxt_obj_size(object) * instance; in mxt_prepare_cfg_mem()
1469 ret = sscanf(cfg->raw + cfg->raw_pos, "%hhx%n", in mxt_prepare_cfg_mem()
1475 return -EINVAL; in mxt_prepare_cfg_mem()
1477 cfg->raw_pos += offset; in mxt_prepare_cfg_mem()
1482 byte_offset = reg + i - cfg->start_ofs; in mxt_prepare_cfg_mem()
1484 if (byte_offset >= 0 && byte_offset < cfg->mem_size) { in mxt_prepare_cfg_mem()
1485 *(cfg->mem + byte_offset) = val; in mxt_prepare_cfg_mem()
1488 reg, object->type, byte_offset); in mxt_prepare_cfg_mem()
1489 return -EINVAL; in mxt_prepare_cfg_mem()
1503 while (byte_offset < cfg->mem_size) { in mxt_upload_cfg_mem()
1504 unsigned int size = cfg->mem_size - byte_offset; in mxt_upload_cfg_mem()
1509 error = __mxt_write_reg(data->client, in mxt_upload_cfg_mem()
1510 cfg->start_ofs + byte_offset, in mxt_upload_cfg_mem()
1511 size, cfg->mem + byte_offset); in mxt_upload_cfg_mem()
1513 dev_err(&data->client->dev, in mxt_upload_cfg_mem()
1527 * mxt_update_cfg - download configuration to chip
1534 * 3) Chip Information Block 24-bit CRC Checksum
1535 * 4) Chip Configuration 24-bit CRC Checksum
1540 * <TYPE> - 2-byte object type as hex
1541 * <INSTANCE> - 2-byte object instance number as hex
1542 * <SIZE> - 2-byte object size as hex
1543 * <CONTENTS> - array of <SIZE> 1-byte hex values
1547 struct device *dev = &data->client->dev; in mxt_update_cfg()
1556 cfg.raw = kmemdup_nul(fw->data, fw->size, GFP_KERNEL); in mxt_update_cfg()
1558 return -ENOMEM; in mxt_update_cfg()
1560 cfg.raw_size = fw->size; in mxt_update_cfg()
1566 ret = -EINVAL; in mxt_update_cfg()
1579 ret = -EINVAL; in mxt_update_cfg()
1586 if (cfg.info.family_id != data->info->family_id) { in mxt_update_cfg()
1588 ret = -EINVAL; in mxt_update_cfg()
1592 if (cfg.info.variant_id != data->info->variant_id) { in mxt_update_cfg()
1594 ret = -EINVAL; in mxt_update_cfg()
1602 ret = -EINVAL; in mxt_update_cfg()
1610 ret = -EINVAL; in mxt_update_cfg()
1621 if (info_crc == data->info_crc) { in mxt_update_cfg()
1622 if (config_crc == 0 || data->config_crc == 0) { in mxt_update_cfg()
1624 } else if (config_crc == data->config_crc) { in mxt_update_cfg()
1626 data->config_crc); in mxt_update_cfg()
1631 data->config_crc, config_crc); in mxt_update_cfg()
1635 "Warning: Info CRC error - device=0x%06X file=0x%06X\n", in mxt_update_cfg()
1636 data->info_crc, info_crc); in mxt_update_cfg()
1641 data->info->object_num * sizeof(struct mxt_object) + in mxt_update_cfg()
1643 cfg.mem_size = data->mem_size - cfg.start_ofs; in mxt_update_cfg()
1646 ret = -ENOMEM; in mxt_update_cfg()
1655 if (data->T71_address) in mxt_update_cfg()
1656 crc_start = data->T71_address; in mxt_update_cfg()
1657 else if (data->T7_address) in mxt_update_cfg()
1658 crc_start = data->T7_address; in mxt_update_cfg()
1664 crc_start - cfg.start_ofs, in mxt_update_cfg()
1700 if (data->input_dev) { in mxt_free_input_device()
1701 input_unregister_device(data->input_dev); in mxt_free_input_device()
1702 data->input_dev = NULL; in mxt_free_input_device()
1709 video_unregister_device(&data->dbg.vdev); in mxt_free_object_table()
1710 v4l2_device_unregister(&data->dbg.v4l2); in mxt_free_object_table()
1712 data->object_table = NULL; in mxt_free_object_table()
1713 data->info = NULL; in mxt_free_object_table()
1714 kfree(data->raw_info_block); in mxt_free_object_table()
1715 data->raw_info_block = NULL; in mxt_free_object_table()
1716 kfree(data->msg_buf); in mxt_free_object_table()
1717 data->msg_buf = NULL; in mxt_free_object_table()
1718 data->T5_address = 0; in mxt_free_object_table()
1719 data->T5_msg_size = 0; in mxt_free_object_table()
1720 data->T6_reportid = 0; in mxt_free_object_table()
1721 data->T7_address = 0; in mxt_free_object_table()
1722 data->T71_address = 0; in mxt_free_object_table()
1723 data->T9_reportid_min = 0; in mxt_free_object_table()
1724 data->T9_reportid_max = 0; in mxt_free_object_table()
1725 data->T15_reportid_min = 0; in mxt_free_object_table()
1726 data->T15_reportid_max = 0; in mxt_free_object_table()
1727 data->T18_address = 0; in mxt_free_object_table()
1728 data->T19_reportid = 0; in mxt_free_object_table()
1729 data->T44_address = 0; in mxt_free_object_table()
1730 data->T97_reportid_min = 0; in mxt_free_object_table()
1731 data->T97_reportid_max = 0; in mxt_free_object_table()
1732 data->T100_reportid_min = 0; in mxt_free_object_table()
1733 data->T100_reportid_max = 0; in mxt_free_object_table()
1734 data->max_reportid = 0; in mxt_free_object_table()
1740 struct i2c_client *client = data->client; in mxt_parse_object_table()
1747 data->mem_size = 0; in mxt_parse_object_table()
1748 for (i = 0; i < data->info->object_num; i++) { in mxt_parse_object_table()
1752 le16_to_cpus(&object->start_address); in mxt_parse_object_table()
1754 if (object->num_report_ids) { in mxt_parse_object_table()
1756 reportid += object->num_report_ids * in mxt_parse_object_table()
1758 max_id = reportid - 1; in mxt_parse_object_table()
1764 dev_dbg(&data->client->dev, in mxt_parse_object_table()
1765 "T%u Start:%u Size:%zu Instances:%zu Report IDs:%u-%u\n", in mxt_parse_object_table()
1766 object->type, object->start_address, in mxt_parse_object_table()
1770 switch (object->type) { in mxt_parse_object_table()
1772 if (data->info->family_id == 0x80 && in mxt_parse_object_table()
1773 data->info->version < 0x20) { in mxt_parse_object_table()
1779 data->T5_msg_size = mxt_obj_size(object); in mxt_parse_object_table()
1782 data->T5_msg_size = mxt_obj_size(object) - 1; in mxt_parse_object_table()
1784 data->T5_address = object->start_address; in mxt_parse_object_table()
1787 data->T6_reportid = min_id; in mxt_parse_object_table()
1788 data->T6_address = object->start_address; in mxt_parse_object_table()
1791 data->T7_address = object->start_address; in mxt_parse_object_table()
1794 data->T71_address = object->start_address; in mxt_parse_object_table()
1797 data->multitouch = MXT_TOUCH_MULTI_T9; in mxt_parse_object_table()
1799 data->T9_reportid_min = min_id; in mxt_parse_object_table()
1800 data->T9_reportid_max = min_id + in mxt_parse_object_table()
1801 object->num_report_ids - 1; in mxt_parse_object_table()
1802 data->num_touchids = object->num_report_ids; in mxt_parse_object_table()
1805 data->T15_reportid_min = min_id; in mxt_parse_object_table()
1806 data->T15_reportid_max = max_id; in mxt_parse_object_table()
1809 data->T18_address = object->start_address; in mxt_parse_object_table()
1812 data->T44_address = object->start_address; in mxt_parse_object_table()
1815 data->T19_reportid = min_id; in mxt_parse_object_table()
1818 data->T97_reportid_min = min_id; in mxt_parse_object_table()
1819 data->T97_reportid_max = max_id; in mxt_parse_object_table()
1822 data->multitouch = MXT_TOUCH_MULTITOUCHSCREEN_T100; in mxt_parse_object_table()
1823 data->T100_reportid_min = min_id; in mxt_parse_object_table()
1824 data->T100_reportid_max = max_id; in mxt_parse_object_table()
1826 data->num_touchids = object->num_report_ids - 2; in mxt_parse_object_table()
1830 end_address = object->start_address in mxt_parse_object_table()
1831 + mxt_obj_size(object) * mxt_obj_instances(object) - 1; in mxt_parse_object_table()
1833 if (end_address >= data->mem_size) in mxt_parse_object_table()
1834 data->mem_size = end_address + 1; in mxt_parse_object_table()
1838 data->max_reportid = reportid; in mxt_parse_object_table()
1841 if (data->T44_address && (data->T5_address != data->T44_address + 1)) { in mxt_parse_object_table()
1842 dev_err(&client->dev, "Invalid T44 position\n"); in mxt_parse_object_table()
1843 return -EINVAL; in mxt_parse_object_table()
1846 data->msg_buf = kcalloc(data->max_reportid, in mxt_parse_object_table()
1847 data->T5_msg_size, GFP_KERNEL); in mxt_parse_object_table()
1848 if (!data->msg_buf) in mxt_parse_object_table()
1849 return -ENOMEM; in mxt_parse_object_table()
1856 struct i2c_client *client = data->client; in mxt_read_info_block()
1865 if (data->raw_info_block) in mxt_read_info_block()
1868 /* Read 7-byte ID information block starting at address 0 */ in mxt_read_info_block()
1872 return -ENOMEM; in mxt_read_info_block()
1879 num_objects = ((struct mxt_info *)id_buf)->object_num; in mxt_read_info_block()
1885 error = -ENOMEM; in mxt_read_info_block()
1892 size - MXT_OBJECT_START, in mxt_read_info_block()
1898 crc_ptr = id_buf + size - MXT_INFO_CHECKSUM_SIZE; in mxt_read_info_block()
1899 data->info_crc = crc_ptr[0] | (crc_ptr[1] << 8) | (crc_ptr[2] << 16); in mxt_read_info_block()
1902 size - MXT_INFO_CHECKSUM_SIZE); in mxt_read_info_block()
1906 * issue or else device is not using Object Based Protocol (eg i2c-hid) in mxt_read_info_block()
1908 if ((data->info_crc == 0) || (data->info_crc != calculated_crc)) { in mxt_read_info_block()
1909 dev_err(&client->dev, in mxt_read_info_block()
1911 calculated_crc, data->info_crc); in mxt_read_info_block()
1912 error = -EIO; in mxt_read_info_block()
1916 data->raw_info_block = id_buf; in mxt_read_info_block()
1917 data->info = (struct mxt_info *)id_buf; in mxt_read_info_block()
1919 dev_info(&client->dev, in mxt_read_info_block()
1921 data->info->family_id, data->info->variant_id, in mxt_read_info_block()
1922 data->info->version >> 4, data->info->version & 0xf, in mxt_read_info_block()
1923 data->info->build, data->info->object_num); in mxt_read_info_block()
1928 dev_err(&client->dev, "Error %d parsing object table\n", error); in mxt_read_info_block()
1933 data->object_table = (struct mxt_object *)(id_buf + MXT_OBJECT_START); in mxt_read_info_block()
1944 struct i2c_client *client = data->client; in mxt_read_t9_resolution()
1952 return -EINVAL; in mxt_read_t9_resolution()
1955 object->start_address + MXT_T9_XSIZE, in mxt_read_t9_resolution()
1956 sizeof(data->xsize), &data->xsize); in mxt_read_t9_resolution()
1961 object->start_address + MXT_T9_YSIZE, in mxt_read_t9_resolution()
1962 sizeof(data->ysize), &data->ysize); in mxt_read_t9_resolution()
1967 object->start_address + MXT_T9_RANGE, in mxt_read_t9_resolution()
1972 data->max_x = get_unaligned_le16(&range.x); in mxt_read_t9_resolution()
1973 data->max_y = get_unaligned_le16(&range.y); in mxt_read_t9_resolution()
1976 object->start_address + MXT_T9_ORIENT, in mxt_read_t9_resolution()
1981 data->xy_switch = orient & MXT_T9_ORIENT_SWITCH; in mxt_read_t9_resolution()
1982 data->invertx = orient & MXT_T9_ORIENT_INVERTX; in mxt_read_t9_resolution()
1983 data->inverty = orient & MXT_T9_ORIENT_INVERTY; in mxt_read_t9_resolution()
1990 struct i2c_client *client = data->client; in mxt_read_t100_config()
1999 return -EINVAL; in mxt_read_t100_config()
2003 object->start_address + MXT_T100_XRANGE, in mxt_read_t100_config()
2008 data->max_x = get_unaligned_le16(&range_x); in mxt_read_t100_config()
2011 object->start_address + MXT_T100_YRANGE, in mxt_read_t100_config()
2016 data->max_y = get_unaligned_le16(&range_y); in mxt_read_t100_config()
2019 object->start_address + MXT_T100_XSIZE, in mxt_read_t100_config()
2020 sizeof(data->xsize), &data->xsize); in mxt_read_t100_config()
2025 object->start_address + MXT_T100_YSIZE, in mxt_read_t100_config()
2026 sizeof(data->ysize), &data->ysize); in mxt_read_t100_config()
2032 object->start_address + MXT_T100_CFG1, in mxt_read_t100_config()
2037 data->xy_switch = cfg & MXT_T100_CFG_SWITCHXY; in mxt_read_t100_config()
2038 data->invertx = cfg & MXT_T100_CFG_INVERTX; in mxt_read_t100_config()
2039 data->inverty = cfg & MXT_T100_CFG_INVERTY; in mxt_read_t100_config()
2043 object->start_address + MXT_T100_TCHAUX, in mxt_read_t100_config()
2051 data->t100_aux_vect = aux++; in mxt_read_t100_config()
2054 data->t100_aux_ampl = aux++; in mxt_read_t100_config()
2057 data->t100_aux_area = aux++; in mxt_read_t100_config()
2059 dev_dbg(&client->dev, in mxt_read_t100_config()
2061 data->t100_aux_vect, data->t100_aux_ampl, data->t100_aux_area); in mxt_read_t100_config()
2074 input_dev->name = "Atmel maXTouch Touchpad"; in mxt_set_up_as_touchpad()
2076 __set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit); in mxt_set_up_as_touchpad()
2085 for (i = 0; i < data->t19_num_keys; i++) in mxt_set_up_as_touchpad()
2086 if (data->t19_keymap[i] != KEY_RESERVED) in mxt_set_up_as_touchpad()
2088 data->t19_keymap[i]); in mxt_set_up_as_touchpad()
2093 struct device *dev = &data->client->dev; in mxt_initialize_input_device()
2100 switch (data->multitouch) { in mxt_initialize_input_device()
2102 num_mt_slots = data->T9_reportid_max - data->T9_reportid_min + 1; in mxt_initialize_input_device()
2109 num_mt_slots = data->num_touchids; in mxt_initialize_input_device()
2117 return -EINVAL; in mxt_initialize_input_device()
2121 if (data->max_x == 0) in mxt_initialize_input_device()
2122 data->max_x = 1023; in mxt_initialize_input_device()
2124 if (data->max_y == 0) in mxt_initialize_input_device()
2125 data->max_y = 1023; in mxt_initialize_input_device()
2127 if (data->xy_switch) in mxt_initialize_input_device()
2128 swap(data->max_x, data->max_y); in mxt_initialize_input_device()
2130 dev_info(dev, "Touchscreen size X%uY%u\n", data->max_x, data->max_y); in mxt_initialize_input_device()
2135 return -ENOMEM; in mxt_initialize_input_device()
2137 input_dev->name = "Atmel maXTouch Touchscreen"; in mxt_initialize_input_device()
2138 input_dev->phys = data->phys; in mxt_initialize_input_device()
2139 input_dev->id.bustype = BUS_I2C; in mxt_initialize_input_device()
2140 input_dev->dev.parent = dev; in mxt_initialize_input_device()
2141 input_dev->open = mxt_input_open; in mxt_initialize_input_device()
2142 input_dev->close = mxt_input_close; in mxt_initialize_input_device()
2144 input_dev->keycode = data->t15_keymap; in mxt_initialize_input_device()
2145 input_dev->keycodemax = data->t15_num_keys; in mxt_initialize_input_device()
2146 input_dev->keycodesize = sizeof(data->t15_keymap[0]); in mxt_initialize_input_device()
2150 /* For single touch */ in mxt_initialize_input_device()
2151 input_set_abs_params(input_dev, ABS_X, 0, data->max_x, 0, 0); in mxt_initialize_input_device()
2152 input_set_abs_params(input_dev, ABS_Y, 0, data->max_y, 0, 0); in mxt_initialize_input_device()
2154 if (data->multitouch == MXT_TOUCH_MULTI_T9 || in mxt_initialize_input_device()
2155 (data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100 && in mxt_initialize_input_device()
2156 data->t100_aux_ampl)) { in mxt_initialize_input_device()
2161 if (data->t19_num_keys) { in mxt_initialize_input_device()
2168 /* For multi touch */ in mxt_initialize_input_device()
2175 if (data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100) { in mxt_initialize_input_device()
2185 0, data->max_x, 0, 0); in mxt_initialize_input_device()
2187 0, data->max_y, 0, 0); in mxt_initialize_input_device()
2189 if (data->multitouch == MXT_TOUCH_MULTI_T9 || in mxt_initialize_input_device()
2190 (data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100 && in mxt_initialize_input_device()
2191 data->t100_aux_area)) { in mxt_initialize_input_device()
2196 if (data->multitouch == MXT_TOUCH_MULTI_T9 || in mxt_initialize_input_device()
2197 (data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100 && in mxt_initialize_input_device()
2198 data->t100_aux_ampl)) { in mxt_initialize_input_device()
2203 if (data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100 && in mxt_initialize_input_device()
2204 data->t100_aux_vect) { in mxt_initialize_input_device()
2209 if (data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100 && in mxt_initialize_input_device()
2210 data->t100_aux_vect) { in mxt_initialize_input_device()
2216 if (data->T15_reportid_min || data->T97_reportid_min) { in mxt_initialize_input_device()
2217 for (i = 0; i < data->t15_num_keys; i++) in mxt_initialize_input_device()
2219 EV_KEY, data->t15_keymap[i]); in mxt_initialize_input_device()
2230 data->input_dev = input_dev; in mxt_initialize_input_device()
2250 struct i2c_client *client = data->client; in mxt_initialize()
2262 dev_info(&client->dev, "Trying alternate bootloader address\n"); in mxt_initialize()
2272 dev_err(&client->dev, "Could not recover from bootloader mode\n"); in mxt_initialize()
2277 data->in_bootloader = true; in mxt_initialize()
2295 &client->dev, GFP_KERNEL, data, in mxt_initialize()
2298 dev_err(&client->dev, "Failed to invoke firmware loader: %d\n", in mxt_initialize()
2308 struct device *dev = &data->client->dev; in mxt_set_t7_power_cfg()
2316 new_config = &data->t7_cfg; in mxt_set_t7_power_cfg()
2318 error = __mxt_write_reg(data->client, data->T7_address, in mxt_set_t7_power_cfg()
2319 sizeof(data->t7_cfg), new_config); in mxt_set_t7_power_cfg()
2324 new_config->active, new_config->idle); in mxt_set_t7_power_cfg()
2331 struct device *dev = &data->client->dev; in mxt_init_t7_power_cfg()
2336 error = __mxt_read_reg(data->client, data->T7_address, in mxt_init_t7_power_cfg()
2337 sizeof(data->t7_cfg), &data->t7_cfg); in mxt_init_t7_power_cfg()
2341 if (data->t7_cfg.active == 0 || data->t7_cfg.idle == 0) { in mxt_init_t7_power_cfg()
2349 data->t7_cfg.active = 20; in mxt_init_t7_power_cfg()
2350 data->t7_cfg.idle = 100; in mxt_init_t7_power_cfg()
2356 data->t7_cfg.active, data->t7_cfg.idle); in mxt_init_t7_power_cfg()
2374 struct mxt_info *info = data->info; in mxt_get_debug_value()
2375 struct mxt_dbg *dbg = &data->dbg; in mxt_get_debug_value()
2380 if (info->family_id == MXT_FAMILY_1386) { in mxt_get_debug_value()
2381 col_width = info->matrix_ysize / MXT1386_COLUMNS; in mxt_get_debug_value()
2385 col_width = info->matrix_ysize; in mxt_get_debug_value()
2392 if (info->family_id == MXT_FAMILY_1386) in mxt_get_debug_value()
2395 return get_unaligned_le16(&dbg->t37_buf[page].data[ofs]); in mxt_get_debug_value()
2400 struct mxt_dbg *dbg = &data->dbg; in mxt_convert_debug_pages()
2405 for (i = 0; i < dbg->t37_nodes; i++) { in mxt_convert_debug_pages()
2407 rx = data->xy_switch ? y : x; in mxt_convert_debug_pages()
2408 ry = data->xy_switch ? x : y; in mxt_convert_debug_pages()
2409 rx = data->invertx ? (data->xsize - 1 - rx) : rx; in mxt_convert_debug_pages()
2410 ry = data->inverty ? (data->ysize - 1 - ry) : ry; in mxt_convert_debug_pages()
2415 if (++x >= (data->xy_switch ? data->ysize : data->xsize)) { in mxt_convert_debug_pages()
2427 struct mxt_dbg *dbg = &data->dbg; in mxt_read_diagnostic_debug()
2435 for (page = 0; page < dbg->t37_pages; page++) { in mxt_read_diagnostic_debug()
2436 p = dbg->t37_buf + page; in mxt_read_diagnostic_debug()
2438 ret = mxt_write_reg(data->client, dbg->diag_cmd_address, in mxt_read_diagnostic_debug()
2447 ret = __mxt_read_reg(data->client, dbg->diag_cmd_address, in mxt_read_diagnostic_debug()
2455 return -EINVAL; in mxt_read_diagnostic_debug()
2462 ret = __mxt_read_reg(data->client, dbg->t37_address, in mxt_read_diagnostic_debug()
2467 if (p->mode != mode || p->page != page) { in mxt_read_diagnostic_debug()
2468 dev_err(&data->client->dev, "T37 page mismatch\n"); in mxt_read_diagnostic_debug()
2469 return -EINVAL; in mxt_read_diagnostic_debug()
2472 dev_dbg(&data->client->dev, "%s page:%d retries:%d\n", in mxt_read_diagnostic_debug()
2486 struct mxt_data *data = q->drv_priv; in mxt_queue_setup()
2487 size_t size = data->dbg.t37_nodes * sizeof(u16); in mxt_queue_setup()
2490 return sizes[0] < size ? -EINVAL : 0; in mxt_queue_setup()
2500 struct mxt_data *data = vb2_get_drv_priv(vb->vb2_queue); in mxt_buffer_queue()
2507 dev_err(&data->client->dev, "Error acquiring frame ptr\n"); in mxt_buffer_queue()
2511 switch (data->dbg.input) { in mxt_buffer_queue()
2526 vb2_set_plane_payload(vb, 0, data->dbg.t37_nodes * sizeof(u16)); in mxt_buffer_queue()
2557 strscpy(cap->driver, "atmel_mxt_ts", sizeof(cap->driver)); in mxt_vidioc_querycap()
2558 strscpy(cap->card, "atmel_mxt_ts touch", sizeof(cap->card)); in mxt_vidioc_querycap()
2559 snprintf(cap->bus_info, sizeof(cap->bus_info), in mxt_vidioc_querycap()
2560 "I2C:%s", dev_name(&data->client->dev)); in mxt_vidioc_querycap()
2567 if (i->index >= MXT_V4L_INPUT_MAX) in mxt_vidioc_enum_input()
2568 return -EINVAL; in mxt_vidioc_enum_input()
2570 i->type = V4L2_INPUT_TYPE_TOUCH; in mxt_vidioc_enum_input()
2572 switch (i->index) { in mxt_vidioc_enum_input()
2574 strscpy(i->name, "Mutual Capacitance References", in mxt_vidioc_enum_input()
2575 sizeof(i->name)); in mxt_vidioc_enum_input()
2578 strscpy(i->name, "Mutual Capacitance Deltas", sizeof(i->name)); in mxt_vidioc_enum_input()
2587 struct v4l2_pix_format *f = &data->dbg.format; in mxt_set_input()
2590 return -EINVAL; in mxt_set_input()
2593 f->pixelformat = V4L2_TCH_FMT_DELTA_TD16; in mxt_set_input()
2595 f->pixelformat = V4L2_TCH_FMT_TU16; in mxt_set_input()
2597 f->width = data->xy_switch ? data->ysize : data->xsize; in mxt_set_input()
2598 f->height = data->xy_switch ? data->xsize : data->ysize; in mxt_set_input()
2599 f->field = V4L2_FIELD_NONE; in mxt_set_input()
2600 f->colorspace = V4L2_COLORSPACE_RAW; in mxt_set_input()
2601 f->bytesperline = f->width * sizeof(u16); in mxt_set_input()
2602 f->sizeimage = f->width * f->height * sizeof(u16); in mxt_set_input()
2604 data->dbg.input = i; in mxt_set_input()
2618 *i = data->dbg.input; in mxt_vidioc_g_input()
2627 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in mxt_vidioc_fmt()
2628 f->fmt.pix = data->dbg.format; in mxt_vidioc_fmt()
2636 if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) in mxt_vidioc_enum_fmt()
2637 return -EINVAL; in mxt_vidioc_enum_fmt()
2639 switch (fmt->index) { in mxt_vidioc_enum_fmt()
2641 fmt->pixelformat = V4L2_TCH_FMT_TU16; in mxt_vidioc_enum_fmt()
2645 fmt->pixelformat = V4L2_TCH_FMT_DELTA_TD16; in mxt_vidioc_enum_fmt()
2649 return -EINVAL; in mxt_vidioc_enum_fmt()
2658 if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) in mxt_vidioc_g_parm()
2659 return -EINVAL; in mxt_vidioc_g_parm()
2661 a->parm.capture.readbuffers = 1; in mxt_vidioc_g_parm()
2662 a->parm.capture.timeperframe.numerator = 1; in mxt_vidioc_g_parm()
2663 a->parm.capture.timeperframe.denominator = 10; in mxt_vidioc_g_parm()
2702 struct mxt_info *info = data->info; in mxt_debug_init()
2703 struct mxt_dbg *dbg = &data->dbg; in mxt_debug_init()
2711 dbg->diag_cmd_address = object->start_address + MXT_COMMAND_DIAGNOSTIC; in mxt_debug_init()
2718 dev_warn(&data->client->dev, "Bad T37 size"); in mxt_debug_init()
2722 dbg->t37_address = object->start_address; in mxt_debug_init()
2725 dbg->t37_nodes = data->xsize * data->ysize; in mxt_debug_init()
2727 if (info->family_id == MXT_FAMILY_1386) in mxt_debug_init()
2728 dbg->t37_pages = MXT1386_COLUMNS * MXT1386_PAGES_PER_COLUMN; in mxt_debug_init()
2730 dbg->t37_pages = DIV_ROUND_UP(data->xsize * in mxt_debug_init()
2731 info->matrix_ysize * in mxt_debug_init()
2733 sizeof(dbg->t37_buf->data)); in mxt_debug_init()
2735 dbg->t37_buf = devm_kmalloc_array(&data->client->dev, dbg->t37_pages, in mxt_debug_init()
2737 if (!dbg->t37_buf) in mxt_debug_init()
2744 snprintf(dbg->v4l2.name, sizeof(dbg->v4l2.name), "%s", "atmel_mxt_ts"); in mxt_debug_init()
2745 error = v4l2_device_register(&data->client->dev, &dbg->v4l2); in mxt_debug_init()
2750 mutex_init(&dbg->lock); in mxt_debug_init()
2751 dbg->queue = mxt_queue; in mxt_debug_init()
2752 dbg->queue.drv_priv = data; in mxt_debug_init()
2753 dbg->queue.lock = &dbg->lock; in mxt_debug_init()
2754 dbg->queue.dev = &data->client->dev; in mxt_debug_init()
2756 error = vb2_queue_init(&dbg->queue); in mxt_debug_init()
2760 dbg->vdev = mxt_video_device; in mxt_debug_init()
2761 dbg->vdev.v4l2_dev = &dbg->v4l2; in mxt_debug_init()
2762 dbg->vdev.lock = &dbg->lock; in mxt_debug_init()
2763 dbg->vdev.vfl_dir = VFL_DIR_RX; in mxt_debug_init()
2764 dbg->vdev.queue = &dbg->queue; in mxt_debug_init()
2765 video_set_drvdata(&dbg->vdev, data); in mxt_debug_init()
2767 error = video_register_device(&dbg->vdev, VFL_TYPE_TOUCH, -1); in mxt_debug_init()
2774 v4l2_device_unregister(&dbg->v4l2); in mxt_debug_init()
2776 dev_warn(&data->client->dev, "Error initializing T37\n"); in mxt_debug_init()
2787 struct device *dev = &data->client->dev; in mxt_configure_objects()
2802 if (data->multitouch) { in mxt_configure_objects()
2807 dev_warn(dev, "No touch object detected\n"); in mxt_configure_objects()
2820 struct mxt_info *info = data->info; in mxt_fw_version_show()
2822 info->version >> 4, info->version & 0xf, info->build); in mxt_fw_version_show()
2830 struct mxt_info *info = data->info; in mxt_hw_version_show()
2831 return sysfs_emit(buf, "%u.%u\n", info->family_id, info->variant_id); in mxt_hw_version_show()
2861 /* Pre-allocate buffer large enough to hold max sized object. */ in mxt_object_show()
2864 return -ENOMEM; in mxt_object_show()
2867 for (i = 0; i < data->info->object_num; i++) { in mxt_object_show()
2868 object = data->object_table + i; in mxt_object_show()
2870 if (!mxt_object_readable(object->type)) in mxt_object_show()
2873 count += sysfs_emit_at(buf, count, "T%u:\n", object->type); in mxt_object_show()
2877 u16 addr = object->start_address + j * size; in mxt_object_show()
2879 error = __mxt_read_reg(data->client, addr, size, obuf); in mxt_object_show()
2898 while (pos < fw->size) { in mxt_check_firmware_format()
2899 c = *(fw->data + pos); in mxt_check_firmware_format()
2909 * xxd -r -p mXTXXX__APP_VX-X-XX.enc > maxtouch.fw in mxt_check_firmware_format()
2913 return -EINVAL; in mxt_check_firmware_format()
2937 if (!data->in_bootloader) { in mxt_load_fw()
2939 data->in_bootloader = true; in mxt_load_fw()
2956 enable_irq(data->irq); in mxt_load_fw()
2959 reinit_completion(&data->bl_completion); in mxt_load_fw()
2976 while (pos < fw->size) { in mxt_load_fw()
2981 frame_size = ((*(fw->data + pos) << 8) | *(fw->data + pos + 1)); in mxt_load_fw()
2987 ret = mxt_bootloader_write(data, fw->data + pos, frame_size); in mxt_load_fw()
3010 frame, pos, fw->size); in mxt_load_fw()
3014 ret = mxt_wait_for_completion(data, &data->bl_completion, in mxt_load_fw()
3026 mxt_wait_for_completion(data, &data->bl_completion, MXT_FW_RESET_TIME); in mxt_load_fw()
3028 data->in_bootloader = false; in mxt_load_fw()
3031 disable_irq(data->irq); in mxt_load_fw()
3076 mxt_wakeup_toggle(data->client, true, false); in mxt_start()
3078 switch (data->suspend_mode) { in mxt_start()
3082 /* Touch enable */ in mxt_start()
3092 /* Recalibrate since chip has been in deep sleep */ in mxt_start()
3100 switch (data->suspend_mode) { in mxt_stop()
3102 /* Touch disable */ in mxt_stop()
3113 mxt_wakeup_toggle(data->client, false, false); in mxt_stop()
3134 static const char keymap_property[] = "linux,gpio-keymap"; in mxt_parse_device_properties()
3136 struct device *dev = &data->client->dev; in mxt_parse_device_properties()
3145 error = n_keys < 0 ? n_keys : -EINVAL; in mxt_parse_device_properties()
3154 return -ENOMEM; in mxt_parse_device_properties()
3164 data->t19_keymap = keymap; in mxt_parse_device_properties()
3165 data->t19_num_keys = n_keys; in mxt_parse_device_properties()
3171 error = n_keys < 0 ? n_keys : -EINVAL; in mxt_parse_device_properties()
3180 return -ENOMEM; in mxt_parse_device_properties()
3190 data->t15_keymap = buttonmap; in mxt_parse_device_properties()
3191 data->t15_num_keys = n_keys; in mxt_parse_device_properties()
3220 * touch screen or touchpad. in mxt_probe()
3222 * So far on x86 the only users of Atmel touch controllers are in mxt_probe()
3226 if (!device_property_present(&client->dev, "compatible")) in mxt_probe()
3227 return -ENXIO; in mxt_probe()
3239 if (ACPI_COMPANION(&client->dev) && client->addr < 0x40) in mxt_probe()
3240 return -ENXIO; in mxt_probe()
3242 data = devm_kzalloc(&client->dev, sizeof(struct mxt_data), GFP_KERNEL); in mxt_probe()
3244 return -ENOMEM; in mxt_probe()
3246 snprintf(data->phys, sizeof(data->phys), "i2c-%u-%04x/input0", in mxt_probe()
3247 client->adapter->nr, client->addr); in mxt_probe()
3249 data->client = client; in mxt_probe()
3250 data->irq = client->irq; in mxt_probe()
3253 init_completion(&data->bl_completion); in mxt_probe()
3254 init_completion(&data->reset_completion); in mxt_probe()
3255 init_completion(&data->crc_completion); in mxt_probe()
3257 data->suspend_mode = dmi_check_system(chromebook_T9_suspend_dmi) ? in mxt_probe()
3268 data->regulators[0].supply = "vdda"; in mxt_probe()
3269 data->regulators[1].supply = "vdd"; in mxt_probe()
3270 error = devm_regulator_bulk_get(&client->dev, ARRAY_SIZE(data->regulators), in mxt_probe()
3271 data->regulators); in mxt_probe()
3273 if (error != -EPROBE_DEFER) in mxt_probe()
3274 dev_err(&client->dev, "Failed to get regulators %d\n", in mxt_probe()
3280 data->reset_gpio = devm_gpiod_get_optional(&client->dev, in mxt_probe()
3282 if (IS_ERR(data->reset_gpio)) { in mxt_probe()
3283 error = PTR_ERR(data->reset_gpio); in mxt_probe()
3284 dev_err(&client->dev, "Failed to get reset gpio: %d\n", error); in mxt_probe()
3289 data->wake_gpio = devm_gpiod_get_optional(&client->dev, in mxt_probe()
3291 if (IS_ERR(data->wake_gpio)) { in mxt_probe()
3292 error = PTR_ERR(data->wake_gpio); in mxt_probe()
3293 dev_err(&client->dev, "Failed to get wake gpio: %d\n", error); in mxt_probe()
3297 error = devm_request_threaded_irq(&client->dev, client->irq, in mxt_probe()
3300 client->name, data); in mxt_probe()
3302 dev_err(&client->dev, "Failed to register interrupt\n"); in mxt_probe()
3306 error = regulator_bulk_enable(ARRAY_SIZE(data->regulators), in mxt_probe()
3307 data->regulators); in mxt_probe()
3309 dev_err(&client->dev, "failed to enable regulators: %d\n", in mxt_probe()
3314 * The device takes 40ms to come up after power-on according in mxt_probe()
3319 if (data->reset_gpio) { in mxt_probe()
3320 /* Wait a while and then de-assert the RESET GPIO line */ in mxt_probe()
3322 gpiod_set_value(data->reset_gpio, 0); in mxt_probe()
3330 * This WAKE line is used for waking controller from a deep-sleep and in mxt_probe()
3332 * could be accepted by controller if it was in a deep-sleep mode. in mxt_probe()
3334 * inactivity if WAKE line is deasserted and deep sleep is activated. in mxt_probe()
3342 device_property_read_u32(&client->dev, "atmel,wakeup-method", in mxt_probe()
3343 &data->wakeup_method); in mxt_probe()
3352 regulator_bulk_disable(ARRAY_SIZE(data->regulators), in mxt_probe()
3353 data->regulators); in mxt_probe()
3361 disable_irq(data->irq); in mxt_remove()
3364 regulator_bulk_disable(ARRAY_SIZE(data->regulators), in mxt_remove()
3365 data->regulators); in mxt_remove()
3372 struct input_dev *input_dev = data->input_dev; in mxt_suspend()
3377 mutex_lock(&input_dev->mutex); in mxt_suspend()
3382 mutex_unlock(&input_dev->mutex); in mxt_suspend()
3384 disable_irq(data->irq); in mxt_suspend()
3393 struct input_dev *input_dev = data->input_dev; in mxt_resume()
3398 enable_irq(data->irq); in mxt_resume()
3400 mutex_lock(&input_dev->mutex); in mxt_resume()
3405 mutex_unlock(&input_dev->mutex); in mxt_resume()