Lines Matching +full:ati +full:- +full:frac +full:- +full:div +full:- +full:fine

1 // SPDX-License-Identifier: GPL-2.0-or-later
52 * The following delay is used during instances that must wait for the open-
124 .name = "event-prox",
131 .name = "event-touch",
138 .name = "event-tap",
145 .name = "event-hold",
152 .name = "event-swipe-x-neg",
159 .name = "event-swipe-x-pos",
166 .name = "event-swipe-y-pos",
173 .name = "event-swipe-y-neg",
187 .name = "event-tap",
194 .name = "event-hold",
201 .name = "event-swipe-x-neg",
208 .name = "event-swipe-x-pos",
215 .name = "event-swipe-y-pos",
222 .name = "event-swipe-y-neg",
236 .name = "event-tap",
243 .name = "event-tap-double",
250 .name = "event-tap-triple",
257 .name = "event-hold",
264 .name = "event-palm",
271 .name = "event-swipe-x-pos",
278 .name = "event-swipe-x-neg",
285 .name = "event-swipe-y-pos",
292 .name = "event-swipe-y-neg",
299 .name = "event-swipe-x-pos-hold",
306 .name = "event-swipe-x-neg-hold",
313 .name = "event-swipe-y-pos-hold",
320 .name = "event-swipe-y-neg-hold",
400 .num_ctx = IQS7211_MAX_CTX - 1,
435 .num_ctx = IQS7211_MAX_CTX - 1,
490 .name = "azoteq,ati-frac-div-fine",
508 .label = "ATI fine fractional divider",
511 .name = "azoteq,ati-frac-mult-coarse",
529 .label = "ATI coarse fractional multiplier",
532 .name = "azoteq,ati-frac-div-coarse",
550 .label = "ATI coarse fractional divider",
553 .name = "azoteq,ati-comp-div",
569 .label = "ATI compensation divider",
572 .name = "azoteq,ati-comp-div",
581 .label = "ATI compensation divider",
584 .name = "azoteq,ati-comp-div",
594 .label = "ATI compensation divider",
597 .name = "azoteq,ati-target",
613 .label = "ATI target",
616 .name = "azoteq,ati-base",
623 .label = "ATI base",
626 .name = "azoteq,ati-base",
633 .label = "ATI base",
636 .name = "azoteq,rate-active-ms",
645 .name = "azoteq,rate-touch-ms",
651 .label = "idle-touch mode report rate",
654 .name = "azoteq,rate-idle-ms",
663 .name = "azoteq,rate-lp1-ms",
669 .label = "low-power mode 1 report rate",
672 .name = "azoteq,rate-lp2-ms",
678 .label = "low-power mode 2 report rate",
681 .name = "azoteq,timeout-active-ms",
691 .name = "azoteq,timeout-touch-ms",
698 .label = "idle-touch mode timeout",
701 .name = "azoteq,timeout-idle-ms",
711 .name = "azoteq,timeout-lp1-ms",
718 .label = "low-power mode 1 timeout",
721 .name = "azoteq,timeout-lp2-ms",
733 .name = "azoteq,timeout-lp2-ms",
742 .name = "azoteq,timeout-ati-ms",
750 .label = "ATI error timeout",
753 .name = "azoteq,timeout-ati-ms",
759 .label = "ATI error timeout",
762 .name = "azoteq,timeout-comms-ms",
771 .name = "azoteq,timeout-press-ms",
781 .name = "azoteq,ati-mode",
787 .label = "ATI mode",
790 .name = "azoteq,ati-mode",
796 .label = "ATI mode",
799 .name = "azoteq,sense-mode",
810 .name = "azoteq,sense-mode",
820 .name = "azoteq,fosc-freq",
831 .name = "azoteq,fosc-trim",
842 .name = "azoteq,touch-exit",
858 .name = "azoteq,touch-enter",
888 .name = "azoteq,debounce-exit",
904 .name = "azoteq,debounce-enter",
920 .name = "azoteq,conv-frac",
941 .name = "azoteq,conv-period",
973 .name = "azoteq,contact-split",
984 .name = "azoteq,trim-x",
994 .name = "azoteq,trim-x",
1001 .name = "azoteq,trim-y",
1011 .name = "azoteq,trim-y",
1018 .name = "azoteq,gesture-max-ms",
1028 .name = "azoteq,gesture-mid-ms",
1036 .name = "azoteq,gesture-dist",
1046 .name = "azoteq,gesture-dist",
1056 .name = "azoteq,gesture-min-ms",
1066 .name = "azoteq,gesture-max-ms",
1076 .name = "azoteq,gesture-max-ms",
1086 .name = "azoteq,gesture-dist",
1096 .name = "azoteq,gesture-dist",
1106 .name = "azoteq,gesture-dist-rep",
1114 .name = "azoteq,gesture-dist-rep",
1206 error = readx_poll_timeout(gpiod_get_value_cansleep, iqs7211->irq_gpio, in iqs7211_irq_poll()
1214 if (!iqs7211->reset_gpio) in iqs7211_hard_reset()
1217 gpiod_set_value_cansleep(iqs7211->reset_gpio, 1); in iqs7211_hard_reset()
1224 if (iqs7211->reset_gpio == iqs7211->irq_gpio) in iqs7211_hard_reset()
1229 gpiod_set_value_cansleep(iqs7211->reset_gpio, 0); in iqs7211_hard_reset()
1230 if (iqs7211->reset_gpio == iqs7211->irq_gpio) in iqs7211_hard_reset()
1241 switch (iqs7211->comms_mode) { in iqs7211_force_comms()
1252 return -EINVAL; in iqs7211_force_comms()
1257 * pin. Attempts to do so while RDY is deasserted return an ACK; how- in iqs7211_force_comms()
1260 * Unsolicited communication must be preceded by a special force com- in iqs7211_force_comms()
1268 ret = gpiod_get_value_cansleep(iqs7211->irq_gpio); in iqs7211_force_comms()
1274 ret = i2c_master_send(iqs7211->client, msg_buf, sizeof(msg_buf)); in iqs7211_force_comms()
1277 ret = -EIO; in iqs7211_force_comms()
1292 struct i2c_client *client = iqs7211->client; in iqs7211_read_burst()
1295 .addr = client->addr, in iqs7211_read_burst()
1301 .addr = client->addr, in iqs7211_read_burst()
1318 ret = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg)); in iqs7211_read_burst()
1321 ret = -EIO; in iqs7211_read_burst()
1328 ret = -ENODATA; in iqs7211_read_burst()
1339 dev_err(&client->dev, in iqs7211_read_burst()
1364 struct i2c_client *client = iqs7211->client; in iqs7211_write_burst()
1369 return -ENOMEM; in iqs7211_write_burst()
1391 ret = -EIO; in iqs7211_write_burst()
1406 dev_err(&client->dev, in iqs7211_write_burst()
1421 const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; in iqs7211_start_comms()
1422 struct i2c_client *client = iqs7211->client; in iqs7211_start_comms()
1437 forced_comms = device_property_present(&client->dev, in iqs7211_start_comms()
1438 "azoteq,forced-comms"); in iqs7211_start_comms()
1440 error = device_property_read_u32(&client->dev, in iqs7211_start_comms()
1441 "azoteq,forced-comms-default", &val); in iqs7211_start_comms()
1442 if (error == -EINVAL) { in iqs7211_start_comms()
1443 iqs7211->comms_init = IQS7211_COMMS_MODE_WAIT; in iqs7211_start_comms()
1445 dev_err(&client->dev, in iqs7211_start_comms()
1450 iqs7211->comms_init = forced_comms ? IQS7211_COMMS_MODE_FORCE in iqs7211_start_comms()
1453 iqs7211->comms_init = forced_comms ? IQS7211_COMMS_MODE_WAIT in iqs7211_start_comms()
1457 iqs7211->comms_mode = iqs7211->comms_init; in iqs7211_start_comms()
1461 dev_err(&client->dev, "Failed to reset device: %d\n", error); in iqs7211_start_comms()
1466 &iqs7211->ver_info, in iqs7211_start_comms()
1467 sizeof(iqs7211->ver_info)); in iqs7211_start_comms()
1471 if (le16_to_cpu(iqs7211->ver_info.prod_num) != dev_desc->prod_num) { in iqs7211_start_comms()
1472 dev_err(&client->dev, "Invalid product number: %u\n", in iqs7211_start_comms()
1473 le16_to_cpu(iqs7211->ver_info.prod_num)); in iqs7211_start_comms()
1474 return -EINVAL; in iqs7211_start_comms()
1477 error = iqs7211_read_word(iqs7211, dev_desc->sys_ctrl + 1, in iqs7211_start_comms()
1483 comms_setup |= dev_desc->comms_req; in iqs7211_start_comms()
1485 comms_setup &= ~dev_desc->comms_req; in iqs7211_start_comms()
1487 error = iqs7211_write_word(iqs7211, dev_desc->sys_ctrl + 1, in iqs7211_start_comms()
1488 comms_setup | dev_desc->comms_end); in iqs7211_start_comms()
1493 iqs7211->comms_mode = IQS7211_COMMS_MODE_FORCE; in iqs7211_start_comms()
1495 iqs7211->comms_mode = IQS7211_COMMS_MODE_FREE; in iqs7211_start_comms()
1497 error = iqs7211_read_burst(iqs7211, dev_desc->exp_file, in iqs7211_start_comms()
1498 iqs7211->exp_file, in iqs7211_start_comms()
1499 sizeof(iqs7211->exp_file)); in iqs7211_start_comms()
1503 error = iqs7211_read_burst(iqs7211, dev_desc->tp_config, in iqs7211_start_comms()
1504 &iqs7211->tp_config, in iqs7211_start_comms()
1505 sizeof(iqs7211->tp_config)); in iqs7211_start_comms()
1509 error = iqs7211_write_word(iqs7211, dev_desc->sys_ctrl + 1, in iqs7211_start_comms()
1514 iqs7211->event_mask = comms_setup & ~IQS7211_EVENT_MASK_ALL; in iqs7211_start_comms()
1515 iqs7211->event_mask |= (IQS7211_EVENT_MASK_ATI | IQS7211_EVENT_MODE); in iqs7211_start_comms()
1522 const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; in iqs7211_init_device()
1525 cpu_to_le16(dev_desc->ack_reset), in iqs7211_init_device()
1526 cpu_to_le16(iqs7211->event_mask), in iqs7211_init_device()
1535 error = iqs7211_write_burst(iqs7211, dev_desc->sys_ctrl, sys_ctrl, in iqs7211_init_device()
1540 if (iqs7211->event_mask & dev_desc->comms_req) in iqs7211_init_device()
1541 iqs7211->comms_mode = IQS7211_COMMS_MODE_FORCE; in iqs7211_init_device()
1543 iqs7211->comms_mode = IQS7211_COMMS_MODE_FREE; in iqs7211_init_device()
1546 * Take advantage of the stop-bit disable function, if available, to in iqs7211_init_device()
1550 error = iqs7211_write_word(iqs7211, dev_desc->sys_ctrl + 1, in iqs7211_init_device()
1551 iqs7211->event_mask | dev_desc->comms_end); in iqs7211_init_device()
1555 list_for_each_entry(reg_field, &iqs7211->reg_field_head, list) { in iqs7211_init_device()
1556 u16 new_val = reg_field->val; in iqs7211_init_device()
1558 if (reg_field->mask < U16_MAX) { in iqs7211_init_device()
1561 error = iqs7211_read_word(iqs7211, reg_field->addr, in iqs7211_init_device()
1566 new_val = old_val & ~reg_field->mask; in iqs7211_init_device()
1567 new_val |= reg_field->val; in iqs7211_init_device()
1573 error = iqs7211_write_word(iqs7211, reg_field->addr, new_val); in iqs7211_init_device()
1578 error = iqs7211_write_burst(iqs7211, dev_desc->tp_config, in iqs7211_init_device()
1579 &iqs7211->tp_config, in iqs7211_init_device()
1580 sizeof(iqs7211->tp_config)); in iqs7211_init_device()
1584 if (**iqs7211->cycle_alloc) { in iqs7211_init_device()
1585 error = iqs7211_write_burst(iqs7211, dev_desc->rx_tx_map, in iqs7211_init_device()
1586 &iqs7211->rx_tx_map, in iqs7211_init_device()
1587 dev_desc->num_ctx); in iqs7211_init_device()
1591 for (i = 0; i < sizeof(dev_desc->cycle_limit); i++) { in iqs7211_init_device()
1593 dev_desc->cycle_alloc[i], in iqs7211_init_device()
1594 iqs7211->cycle_alloc[i], in iqs7211_init_device()
1595 dev_desc->cycle_limit[i] * 3); in iqs7211_init_device()
1601 *sys_ctrl = cpu_to_le16(iqs7211->ati_start); in iqs7211_init_device()
1603 return iqs7211_write_burst(iqs7211, dev_desc->sys_ctrl, sys_ctrl, in iqs7211_init_device()
1610 struct i2c_client *client = iqs7211->client; in iqs7211_add_field()
1616 list_for_each_entry(reg_field, &iqs7211->reg_field_head, list) { in iqs7211_add_field()
1617 if (reg_field->addr != new_field.addr) in iqs7211_add_field()
1620 reg_field->mask |= new_field.mask; in iqs7211_add_field()
1621 reg_field->val |= new_field.val; in iqs7211_add_field()
1625 reg_field = devm_kzalloc(&client->dev, sizeof(*reg_field), GFP_KERNEL); in iqs7211_add_field()
1627 return -ENOMEM; in iqs7211_add_field()
1629 reg_field->addr = new_field.addr; in iqs7211_add_field()
1630 reg_field->mask = new_field.mask; in iqs7211_add_field()
1631 reg_field->val = new_field.val; in iqs7211_add_field()
1633 list_add(&reg_field->list, &iqs7211->reg_field_head); in iqs7211_add_field()
1643 struct i2c_client *client = iqs7211->client; in iqs7211_parse_props()
1649 [iqs7211->dev_desc - in iqs7211_parse_props()
1668 if (error == -EINVAL) { in iqs7211_parse_props()
1671 dev_err(&client->dev, "Failed to read %s %s: %d\n", in iqs7211_parse_props()
1677 val_max = GENMASK(reg_width - 1, 0) * val_pitch; in iqs7211_parse_props()
1680 dev_err(&client->dev, "Invalid %s: %u\n", label, val); in iqs7211_parse_props()
1681 return -EINVAL; in iqs7211_parse_props()
1685 reg_field.mask = GENMASK(reg_shift + reg_width - 1, reg_shift); in iqs7211_parse_props()
1702 const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; in iqs7211_parse_event()
1703 struct i2c_client *client = iqs7211->client; in iqs7211_parse_event()
1715 "azoteq,gesture-angle", &val); in iqs7211_parse_event()
1718 dev_err(&client->dev, in iqs7211_parse_event()
1721 return -EINVAL; in iqs7211_parse_event()
1724 reg_field.addr = dev_desc->gesture_angle; in iqs7211_parse_event()
1731 } else if (error != -EINVAL) { in iqs7211_parse_event()
1732 dev_err(&client->dev, in iqs7211_parse_event()
1740 if (error == -EINVAL) in iqs7211_parse_event()
1743 dev_err(&client->dev, "Failed to read %s code: %d\n", in iqs7211_parse_event()
1752 const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; in iqs7211_parse_cycles()
1753 struct i2c_client *client = iqs7211->client; in iqs7211_parse_cycles()
1754 int num_cycles = dev_desc->cycle_limit[0] + dev_desc->cycle_limit[1]; in iqs7211_parse_cycles()
1757 u8 total_rx = iqs7211->tp_config.total_rx; in iqs7211_parse_cycles()
1758 u8 total_tx = iqs7211->tp_config.total_tx; in iqs7211_parse_cycles()
1763 count = fwnode_property_count_u32(tp_node, "azoteq,channel-select"); in iqs7211_parse_cycles()
1764 if (count == -EINVAL) { in iqs7211_parse_cycles()
1775 * Channels formed by CRx0-3 and CRx4-7 are in iqs7211_parse_cycles()
1778 int slot = iqs7211->rx_tx_map[j] < 4 ? 0 : 1; in iqs7211_parse_cycles()
1794 dev_err(&client->dev, in iqs7211_parse_cycles()
1796 return -EINVAL; in iqs7211_parse_cycles()
1807 dev_err(&client->dev, "Failed to count channels: %d\n", count); in iqs7211_parse_cycles()
1810 dev_err(&client->dev, "Insufficient number of cycles\n"); in iqs7211_parse_cycles()
1811 return -EINVAL; in iqs7211_parse_cycles()
1814 "azoteq,channel-select", in iqs7211_parse_cycles()
1817 dev_err(&client->dev, "Failed to read channels: %d\n", in iqs7211_parse_cycles()
1829 dev_err(&client->dev, "Invalid channel: %d\n", in iqs7211_parse_cycles()
1831 return -EINVAL; in iqs7211_parse_cycles()
1838 dev_err(&client->dev, "Duplicate channel: %d\n", in iqs7211_parse_cycles()
1840 return -EINVAL; in iqs7211_parse_cycles()
1849 for (i = 0, cycle_start = 0; i < sizeof(dev_desc->cycle_limit); i++) { in iqs7211_parse_cycles()
1853 j < cycle_start + dev_desc->cycle_limit[i]; j++) { in iqs7211_parse_cycles()
1854 iqs7211->cycle_alloc[i][offs++] = 0x05; in iqs7211_parse_cycles()
1855 iqs7211->cycle_alloc[i][offs++] = cycle_alloc[j][0]; in iqs7211_parse_cycles()
1856 iqs7211->cycle_alloc[i][offs++] = cycle_alloc[j][1]; in iqs7211_parse_cycles()
1859 cycle_start += dev_desc->cycle_limit[i]; in iqs7211_parse_cycles()
1868 const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; in iqs7211_parse_tp()
1869 struct i2c_client *client = iqs7211->client; in iqs7211_parse_tp()
1873 count = fwnode_property_count_u32(tp_node, "azoteq,rx-enable"); in iqs7211_parse_tp()
1874 if (count == -EINVAL) { in iqs7211_parse_tp()
1877 dev_err(&client->dev, "Failed to count CRx pins: %d\n", count); in iqs7211_parse_tp()
1880 dev_err(&client->dev, "Invalid number of CRx pins\n"); in iqs7211_parse_tp()
1881 return -EINVAL; in iqs7211_parse_tp()
1884 error = fwnode_property_read_u32_array(tp_node, "azoteq,rx-enable", in iqs7211_parse_tp()
1887 dev_err(&client->dev, "Failed to read CRx pins: %d\n", error); in iqs7211_parse_tp()
1893 dev_err(&client->dev, "Invalid CRx pin: %u\n", pins[i]); in iqs7211_parse_tp()
1894 return -EINVAL; in iqs7211_parse_tp()
1897 iqs7211->rx_tx_map[i] = pins[i]; in iqs7211_parse_tp()
1900 iqs7211->tp_config.total_rx = count; in iqs7211_parse_tp()
1902 count = fwnode_property_count_u32(tp_node, "azoteq,tx-enable"); in iqs7211_parse_tp()
1904 dev_err(&client->dev, "Failed to count CTx pins: %d\n", count); in iqs7211_parse_tp()
1906 } else if (count > dev_desc->num_ctx) { in iqs7211_parse_tp()
1907 dev_err(&client->dev, "Invalid number of CTx pins\n"); in iqs7211_parse_tp()
1908 return -EINVAL; in iqs7211_parse_tp()
1911 error = fwnode_property_read_u32_array(tp_node, "azoteq,tx-enable", in iqs7211_parse_tp()
1914 dev_err(&client->dev, "Failed to read CTx pins: %d\n", error); in iqs7211_parse_tp()
1919 if (pins[i] >= dev_desc->num_ctx) { in iqs7211_parse_tp()
1920 dev_err(&client->dev, "Invalid CTx pin: %u\n", pins[i]); in iqs7211_parse_tp()
1921 return -EINVAL; in iqs7211_parse_tp()
1924 for (j = 0; j < iqs7211->tp_config.total_rx; j++) { in iqs7211_parse_tp()
1925 if (iqs7211->rx_tx_map[j] != pins[i]) in iqs7211_parse_tp()
1928 dev_err(&client->dev, "Conflicting CTx pin: %u\n", in iqs7211_parse_tp()
1930 return -EINVAL; in iqs7211_parse_tp()
1933 iqs7211->rx_tx_map[iqs7211->tp_config.total_rx + i] = pins[i]; in iqs7211_parse_tp()
1936 iqs7211->tp_config.total_tx = count; in iqs7211_parse_tp()
1944 const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; in iqs7211_parse_alp()
1945 struct i2c_client *client = iqs7211->client; in iqs7211_parse_alp()
1949 count = fwnode_property_count_u32(alp_node, "azoteq,rx-enable"); in iqs7211_parse_alp()
1950 if (count < 0 && count != -EINVAL) { in iqs7211_parse_alp()
1951 dev_err(&client->dev, "Failed to count CRx pins: %d\n", count); in iqs7211_parse_alp()
1954 dev_err(&client->dev, "Invalid number of CRx pins\n"); in iqs7211_parse_alp()
1955 return -EINVAL; in iqs7211_parse_alp()
1960 "azoteq,rx-enable", in iqs7211_parse_alp()
1963 dev_err(&client->dev, "Failed to read CRx pins: %d\n", in iqs7211_parse_alp()
1968 reg_field.addr = dev_desc->alp_config; in iqs7211_parse_alp()
1969 reg_field.mask = GENMASK(IQS7211_NUM_CRX - 1, 0); in iqs7211_parse_alp()
1973 if (pins[i] < dev_desc->min_crx_alp || in iqs7211_parse_alp()
1975 dev_err(&client->dev, "Invalid CRx pin: %u\n", in iqs7211_parse_alp()
1977 return -EINVAL; in iqs7211_parse_alp()
1988 count = fwnode_property_count_u32(alp_node, "azoteq,tx-enable"); in iqs7211_parse_alp()
1989 if (count < 0 && count != -EINVAL) { in iqs7211_parse_alp()
1990 dev_err(&client->dev, "Failed to count CTx pins: %d\n", count); in iqs7211_parse_alp()
1992 } else if (count > dev_desc->num_ctx) { in iqs7211_parse_alp()
1993 dev_err(&client->dev, "Invalid number of CTx pins\n"); in iqs7211_parse_alp()
1994 return -EINVAL; in iqs7211_parse_alp()
1999 "azoteq,tx-enable", in iqs7211_parse_alp()
2002 dev_err(&client->dev, "Failed to read CTx pins: %d\n", in iqs7211_parse_alp()
2007 reg_field.addr = dev_desc->alp_config + 1; in iqs7211_parse_alp()
2008 reg_field.mask = GENMASK(dev_desc->num_ctx - 1, 0); in iqs7211_parse_alp()
2012 if (pins[i] >= dev_desc->num_ctx) { in iqs7211_parse_alp()
2013 dev_err(&client->dev, "Invalid CTx pin: %u\n", in iqs7211_parse_alp()
2015 return -EINVAL; in iqs7211_parse_alp()
2040 const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; in iqs7211_parse_reg_grp()
2055 iqs7211->ati_start |= dev_desc->ati_start[reg_grp]; in iqs7211_parse_reg_grp()
2057 reg_field.addr = dev_desc->kp_enable[reg_grp]; in iqs7211_parse_reg_grp()
2061 for (i = 0; i < dev_desc->num_kp_events; i++) { in iqs7211_parse_reg_grp()
2062 const char *event_name = dev_desc->kp_events[i].name; in iqs7211_parse_reg_grp()
2065 if (dev_desc->kp_events[i].reg_grp != reg_grp) in iqs7211_parse_reg_grp()
2068 reg_field.mask |= dev_desc->kp_events[i].enable; in iqs7211_parse_reg_grp()
2080 dev_desc->kp_events[i].reg_grp, in iqs7211_parse_reg_grp()
2081 dev_desc->kp_events[i].reg_key, in iqs7211_parse_reg_grp()
2082 &iqs7211->kp_code[i]); in iqs7211_parse_reg_grp()
2087 reg_field.val |= dev_desc->kp_events[i].enable; in iqs7211_parse_reg_grp()
2089 iqs7211->event_mask |= iqs7211_reg_grp_masks[reg_grp]; in iqs7211_parse_reg_grp()
2097 const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; in iqs7211_register_kp()
2098 struct input_dev *kp_idev = iqs7211->kp_idev; in iqs7211_register_kp()
2099 struct i2c_client *client = iqs7211->client; in iqs7211_register_kp()
2102 for (i = 0; i < dev_desc->num_kp_events; i++) in iqs7211_register_kp()
2103 if (iqs7211->kp_code[i]) in iqs7211_register_kp()
2106 if (i == dev_desc->num_kp_events) in iqs7211_register_kp()
2109 kp_idev = devm_input_allocate_device(&client->dev); in iqs7211_register_kp()
2111 return -ENOMEM; in iqs7211_register_kp()
2113 iqs7211->kp_idev = kp_idev; in iqs7211_register_kp()
2115 kp_idev->name = dev_desc->kp_name; in iqs7211_register_kp()
2116 kp_idev->id.bustype = BUS_I2C; in iqs7211_register_kp()
2118 for (i = 0; i < dev_desc->num_kp_events; i++) in iqs7211_register_kp()
2119 if (iqs7211->kp_code[i]) in iqs7211_register_kp()
2120 input_set_capability(iqs7211->kp_idev, EV_KEY, in iqs7211_register_kp()
2121 iqs7211->kp_code[i]); in iqs7211_register_kp()
2125 dev_err(&client->dev, "Failed to register %s: %d\n", in iqs7211_register_kp()
2126 kp_idev->name, error); in iqs7211_register_kp()
2133 const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; in iqs7211_register_tp()
2134 struct touchscreen_properties *prop = &iqs7211->prop; in iqs7211_register_tp()
2135 struct input_dev *tp_idev = iqs7211->tp_idev; in iqs7211_register_tp()
2136 struct i2c_client *client = iqs7211->client; in iqs7211_register_tp()
2139 error = device_property_read_u32(&client->dev, "azoteq,num-contacts", in iqs7211_register_tp()
2140 &iqs7211->num_contacts); in iqs7211_register_tp()
2141 if (error == -EINVAL) { in iqs7211_register_tp()
2144 dev_err(&client->dev, "Failed to read number of contacts: %d\n", in iqs7211_register_tp()
2147 } else if (iqs7211->num_contacts > IQS7211_MAX_CONTACTS) { in iqs7211_register_tp()
2148 dev_err(&client->dev, "Invalid number of contacts: %u\n", in iqs7211_register_tp()
2149 iqs7211->num_contacts); in iqs7211_register_tp()
2150 return -EINVAL; in iqs7211_register_tp()
2153 iqs7211->tp_config.num_contacts = iqs7211->num_contacts ? : 1; in iqs7211_register_tp()
2155 if (!iqs7211->num_contacts) in iqs7211_register_tp()
2158 iqs7211->event_mask |= IQS7211_EVENT_MASK_MOVE; in iqs7211_register_tp()
2160 tp_idev = devm_input_allocate_device(&client->dev); in iqs7211_register_tp()
2162 return -ENOMEM; in iqs7211_register_tp()
2164 iqs7211->tp_idev = tp_idev; in iqs7211_register_tp()
2166 tp_idev->name = dev_desc->tp_name; in iqs7211_register_tp()
2167 tp_idev->id.bustype = BUS_I2C; in iqs7211_register_tp()
2170 0, le16_to_cpu(iqs7211->tp_config.max_x), 0, 0); in iqs7211_register_tp()
2173 0, le16_to_cpu(iqs7211->tp_config.max_y), 0, 0); in iqs7211_register_tp()
2183 if (prop->max_x >= U16_MAX || prop->max_y >= U16_MAX) { in iqs7211_register_tp()
2184 dev_err(&client->dev, "Invalid trackpad size: %u*%u\n", in iqs7211_register_tp()
2185 prop->max_x, prop->max_y); in iqs7211_register_tp()
2186 return -EINVAL; in iqs7211_register_tp()
2189 iqs7211->tp_config.max_x = cpu_to_le16(prop->max_x); in iqs7211_register_tp()
2190 iqs7211->tp_config.max_y = cpu_to_le16(prop->max_y); in iqs7211_register_tp()
2192 error = input_mt_init_slots(tp_idev, iqs7211->num_contacts, in iqs7211_register_tp()
2195 dev_err(&client->dev, "Failed to initialize slots: %d\n", in iqs7211_register_tp()
2202 dev_err(&client->dev, "Failed to register %s: %d\n", in iqs7211_register_tp()
2203 tp_idev->name, error); in iqs7211_register_tp()
2210 const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; in iqs7211_report()
2211 struct i2c_client *client = iqs7211->client; in iqs7211_report()
2217 error = iqs7211_read_burst(iqs7211, dev_desc->sys_stat, status, in iqs7211_report()
2218 dev_desc->contact_offs * sizeof(__le16) + in iqs7211_report()
2219 iqs7211->num_contacts * sizeof(*touch_data)); in iqs7211_report()
2223 info_flags = le16_to_cpu(status[dev_desc->info_offs]); in iqs7211_report()
2225 if (info_flags & dev_desc->show_reset) { in iqs7211_report()
2226 dev_err(&client->dev, "Unexpected device reset\n"); in iqs7211_report()
2233 iqs7211->comms_mode = iqs7211->comms_init; in iqs7211_report()
2238 for (i = 0; i < ARRAY_SIZE(dev_desc->ati_error); i++) { in iqs7211_report()
2239 if (!(info_flags & dev_desc->ati_error[i])) in iqs7211_report()
2242 dev_err(&client->dev, "Unexpected %s ATI error\n", in iqs7211_report()
2247 for (i = 0; i < iqs7211->num_contacts; i++) { in iqs7211_report()
2251 &status[dev_desc->contact_offs] + i; in iqs7211_report()
2252 pressure = le16_to_cpu(touch_data->pressure); in iqs7211_report()
2254 input_mt_slot(iqs7211->tp_idev, i); in iqs7211_report()
2255 if (input_mt_report_slot_state(iqs7211->tp_idev, MT_TOOL_FINGER, in iqs7211_report()
2257 touchscreen_report_pos(iqs7211->tp_idev, &iqs7211->prop, in iqs7211_report()
2258 le16_to_cpu(touch_data->abs_x), in iqs7211_report()
2259 le16_to_cpu(touch_data->abs_y), in iqs7211_report()
2261 input_report_abs(iqs7211->tp_idev, ABS_MT_PRESSURE, in iqs7211_report()
2266 if (iqs7211->num_contacts) { in iqs7211_report()
2267 input_mt_sync_frame(iqs7211->tp_idev); in iqs7211_report()
2268 input_sync(iqs7211->tp_idev); in iqs7211_report()
2271 if (!iqs7211->kp_idev) in iqs7211_report()
2274 charge_mode = info_flags & GENMASK(dev_desc->charge_shift + 2, in iqs7211_report()
2275 dev_desc->charge_shift); in iqs7211_report()
2276 charge_mode >>= dev_desc->charge_shift; in iqs7211_report()
2280 * operated in low-power mode and intends to express an ALP event. in iqs7211_report()
2282 if (info_flags & dev_desc->kp_events->mask && charge_mode > 2) { in iqs7211_report()
2283 input_report_key(iqs7211->kp_idev, *iqs7211->kp_code, 1); in iqs7211_report()
2284 input_sync(iqs7211->kp_idev); in iqs7211_report()
2286 input_report_key(iqs7211->kp_idev, *iqs7211->kp_code, 0); in iqs7211_report()
2289 for (i = 0; i < dev_desc->num_kp_events; i++) { in iqs7211_report()
2290 if (dev_desc->kp_events[i].reg_grp != IQS7211_REG_GRP_BTN) in iqs7211_report()
2293 input_report_key(iqs7211->kp_idev, iqs7211->kp_code[i], in iqs7211_report()
2294 info_flags & dev_desc->kp_events[i].mask); in iqs7211_report()
2297 gesture_flags = le16_to_cpu(status[dev_desc->gesture_offs]); in iqs7211_report()
2299 for (i = 0; i < dev_desc->num_kp_events; i++) { in iqs7211_report()
2300 enum iqs7211_reg_key_id reg_key = dev_desc->kp_events[i].reg_key; in iqs7211_report()
2301 u16 mask = dev_desc->kp_events[i].mask; in iqs7211_report()
2303 if (dev_desc->kp_events[i].reg_grp != IQS7211_REG_GRP_TP) in iqs7211_report()
2306 if ((gesture_flags ^ iqs7211->gesture_cache) & mask) in iqs7211_report()
2307 input_report_key(iqs7211->kp_idev, iqs7211->kp_code[i], in iqs7211_report()
2310 iqs7211->gesture_cache &= ~mask; in iqs7211_report()
2319 iqs7211->gesture_cache |= gesture_flags & mask; in iqs7211_report()
2325 input_sync(iqs7211->kp_idev); in iqs7211_report()
2327 for (i = 0; i < dev_desc->num_kp_events; i++) in iqs7211_report()
2328 if (dev_desc->kp_events[i].reg_grp == IQS7211_REG_GRP_TP && in iqs7211_report()
2329 gesture_flags & dev_desc->kp_events[i].mask) in iqs7211_report()
2330 input_report_key(iqs7211->kp_idev, in iqs7211_report()
2331 iqs7211->kp_code[i], 0); in iqs7211_report()
2334 input_sync(iqs7211->kp_idev); in iqs7211_report()
2349 const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; in iqs7211_suspend()
2352 if (!dev_desc->suspend || device_may_wakeup(dev)) in iqs7211_suspend()
2360 disable_irq(gpiod_to_irq(iqs7211->irq_gpio)); in iqs7211_suspend()
2362 error = iqs7211_write_word(iqs7211, dev_desc->sys_ctrl, in iqs7211_suspend()
2363 dev_desc->suspend); in iqs7211_suspend()
2365 enable_irq(gpiod_to_irq(iqs7211->irq_gpio)); in iqs7211_suspend()
2373 const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; in iqs7211_resume()
2376 cpu_to_le16(iqs7211->event_mask), in iqs7211_resume()
2380 if (!dev_desc->suspend || device_may_wakeup(dev)) in iqs7211_resume()
2383 disable_irq(gpiod_to_irq(iqs7211->irq_gpio)); in iqs7211_resume()
2387 * of the wake-up command. in iqs7211_resume()
2389 error = iqs7211_write_burst(iqs7211, dev_desc->sys_ctrl, sys_ctrl, in iqs7211_resume()
2392 enable_irq(gpiod_to_irq(iqs7211->irq_gpio)); in iqs7211_resume()
2405 le16_to_cpu(iqs7211->ver_info.prod_num), in fw_info_show()
2406 le32_to_cpu(iqs7211->ver_info.patch), in fw_info_show()
2407 le16_to_cpu(iqs7211->ver_info.major), in fw_info_show()
2408 le16_to_cpu(iqs7211->ver_info.minor), in fw_info_show()
2409 iqs7211->exp_file[1], iqs7211->exp_file[0]); in fw_info_show()
2445 iqs7211 = devm_kzalloc(&client->dev, sizeof(*iqs7211), GFP_KERNEL); in iqs7211_probe()
2447 return -ENOMEM; in iqs7211_probe()
2450 iqs7211->client = client; in iqs7211_probe()
2452 INIT_LIST_HEAD(&iqs7211->reg_field_head); in iqs7211_probe()
2454 iqs7211->dev_desc = device_get_match_data(&client->dev); in iqs7211_probe()
2455 if (!iqs7211->dev_desc) in iqs7211_probe()
2456 return -ENODEV; in iqs7211_probe()
2458 shared_irq = iqs7211->dev_desc->num_ctx == IQS7211_MAX_CTX; in iqs7211_probe()
2467 * must be configured as an open-drain output. in iqs7211_probe()
2469 iqs7211->irq_gpio = devm_gpiod_get(&client->dev, "irq", in iqs7211_probe()
2472 if (IS_ERR(iqs7211->irq_gpio)) { in iqs7211_probe()
2473 error = PTR_ERR(iqs7211->irq_gpio); in iqs7211_probe()
2474 dev_err(&client->dev, "Failed to request IRQ GPIO: %d\n", in iqs7211_probe()
2480 iqs7211->reset_gpio = iqs7211->irq_gpio; in iqs7211_probe()
2482 iqs7211->reset_gpio = devm_gpiod_get_optional(&client->dev, in iqs7211_probe()
2485 if (IS_ERR(iqs7211->reset_gpio)) { in iqs7211_probe()
2486 error = PTR_ERR(iqs7211->reset_gpio); in iqs7211_probe()
2487 dev_err(&client->dev, in iqs7211_probe()
2502 reg_grp_node = device_get_named_child_node(&client->dev, in iqs7211_probe()
2505 reg_grp_node = fwnode_handle_get(dev_fwnode(&client->dev)); in iqs7211_probe()
2528 irq = gpiod_to_irq(iqs7211->irq_gpio); in iqs7211_probe()
2532 irq_flags = gpiod_is_active_low(iqs7211->irq_gpio) ? IRQF_TRIGGER_LOW in iqs7211_probe()
2536 error = devm_request_threaded_irq(&client->dev, irq, NULL, iqs7211_irq, in iqs7211_probe()
2537 irq_flags, client->name, iqs7211); in iqs7211_probe()
2539 dev_err(&client->dev, "Failed to request IRQ: %d\n", error); in iqs7211_probe()