Lines Matching refs:iqs7211

1202 static int iqs7211_irq_poll(struct iqs7211_private *iqs7211, u64 timeout_us)  in iqs7211_irq_poll()  argument
1206 error = readx_poll_timeout(gpiod_get_value_cansleep, iqs7211->irq_gpio, in iqs7211_irq_poll()
1212 static int iqs7211_hard_reset(struct iqs7211_private *iqs7211) in iqs7211_hard_reset() argument
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()
1233 return iqs7211_irq_poll(iqs7211, IQS7211_START_TIMEOUT_US); in iqs7211_hard_reset()
1236 static int iqs7211_force_comms(struct iqs7211_private *iqs7211) in iqs7211_force_comms() argument
1241 switch (iqs7211->comms_mode) { in iqs7211_force_comms()
1243 return iqs7211_irq_poll(iqs7211, IQS7211_START_TIMEOUT_US); 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()
1285 return iqs7211_irq_poll(iqs7211, IQS7211_COMMS_TIMEOUT_US); in iqs7211_force_comms()
1288 static int iqs7211_read_burst(struct iqs7211_private *iqs7211, in iqs7211_read_burst() argument
1292 struct i2c_client *client = iqs7211->client; in iqs7211_read_burst()
1314 ret = iqs7211_force_comms(iqs7211); in iqs7211_read_burst()
1345 static int iqs7211_read_word(struct iqs7211_private *iqs7211, u8 reg, u16 *val) in iqs7211_read_word() argument
1350 error = iqs7211_read_burst(iqs7211, reg, &val_buf, sizeof(val_buf)); in iqs7211_read_word()
1359 static int iqs7211_write_burst(struct iqs7211_private *iqs7211, in iqs7211_write_burst() argument
1364 struct i2c_client *client = iqs7211->client; in iqs7211_write_burst()
1384 ret = iqs7211_force_comms(iqs7211); in iqs7211_write_burst()
1412 static int iqs7211_write_word(struct iqs7211_private *iqs7211, u8 reg, u16 val) in iqs7211_write_word() argument
1416 return iqs7211_write_burst(iqs7211, reg, &val_buf, sizeof(val_buf)); in iqs7211_write_word()
1419 static int iqs7211_start_comms(struct iqs7211_private *iqs7211) in iqs7211_start_comms() argument
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()
1443 iqs7211->comms_init = IQS7211_COMMS_MODE_WAIT; 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()
1459 error = iqs7211_hard_reset(iqs7211); in iqs7211_start_comms()
1465 error = iqs7211_read_burst(iqs7211, IQS7211_PROD_NUM, 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()
1473 le16_to_cpu(iqs7211->ver_info.prod_num)); in iqs7211_start_comms()
1477 error = iqs7211_read_word(iqs7211, dev_desc->sys_ctrl + 1, in iqs7211_start_comms()
1487 error = iqs7211_write_word(iqs7211, dev_desc->sys_ctrl + 1, 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()
1520 static int iqs7211_init_device(struct iqs7211_private *iqs7211) in iqs7211_init_device() argument
1522 const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; 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()
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()
1561 error = iqs7211_read_word(iqs7211, reg_field->addr, 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()
1592 error = iqs7211_write_burst(iqs7211, in iqs7211_init_device()
1594 iqs7211->cycle_alloc[i], 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()
1607 static int iqs7211_add_field(struct iqs7211_private *iqs7211, in iqs7211_add_field() argument
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()
1633 list_add(&reg_field->list, &iqs7211->reg_field_head); in iqs7211_add_field()
1638 static int iqs7211_parse_props(struct iqs7211_private *iqs7211, in iqs7211_parse_props() argument
1643 struct i2c_client *client = iqs7211->client; in iqs7211_parse_props()
1649 [iqs7211->dev_desc - in iqs7211_parse_props()
1688 error = iqs7211_add_field(iqs7211, reg_field); in iqs7211_parse_props()
1696 static int iqs7211_parse_event(struct iqs7211_private *iqs7211, in iqs7211_parse_event() argument
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()
1708 error = iqs7211_parse_props(iqs7211, event_node, reg_grp, reg_key); in iqs7211_parse_event()
1728 error = iqs7211_add_field(iqs7211, reg_field); in iqs7211_parse_event()
1749 static int iqs7211_parse_cycles(struct iqs7211_private *iqs7211, in iqs7211_parse_cycles() argument
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()
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()
1778 int slot = iqs7211->rx_tx_map[j] < 4 ? 0 : 1; 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()
1865 static int iqs7211_parse_tp(struct iqs7211_private *iqs7211, in iqs7211_parse_tp() argument
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()
1897 iqs7211->rx_tx_map[i] = pins[i]; in iqs7211_parse_tp()
1900 iqs7211->tp_config.total_rx = count; 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()
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()
1938 return iqs7211_parse_cycles(iqs7211, tp_node); in iqs7211_parse_tp()
1941 static int iqs7211_parse_alp(struct iqs7211_private *iqs7211, in iqs7211_parse_alp() argument
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()
1983 error = iqs7211_add_field(iqs7211, reg_field); in iqs7211_parse_alp()
2021 error = iqs7211_add_field(iqs7211, reg_field); in iqs7211_parse_alp()
2030 (struct iqs7211_private *iqs7211,
2036 static int iqs7211_parse_reg_grp(struct iqs7211_private *iqs7211, in iqs7211_parse_reg_grp() argument
2040 const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; in iqs7211_parse_reg_grp()
2044 error = iqs7211_parse_props(iqs7211, reg_grp_node, reg_grp, in iqs7211_parse_reg_grp()
2050 error = iqs7211_parse_extra[reg_grp](iqs7211, reg_grp_node); in iqs7211_parse_reg_grp()
2055 iqs7211->ati_start |= dev_desc->ati_start[reg_grp]; in iqs7211_parse_reg_grp()
2079 error = iqs7211_parse_event(iqs7211, event_node, in iqs7211_parse_reg_grp()
2082 &iqs7211->kp_code[i]); in iqs7211_parse_reg_grp()
2089 iqs7211->event_mask |= iqs7211_reg_grp_masks[reg_grp]; in iqs7211_parse_reg_grp()
2092 return iqs7211_add_field(iqs7211, reg_field); in iqs7211_parse_reg_grp()
2095 static int iqs7211_register_kp(struct iqs7211_private *iqs7211) in iqs7211_register_kp() argument
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()
2103 if (iqs7211->kp_code[i]) in iqs7211_register_kp()
2113 iqs7211->kp_idev = kp_idev; 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()
2131 static int iqs7211_register_tp(struct iqs7211_private *iqs7211) in iqs7211_register_tp() argument
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()
2140 &iqs7211->num_contacts); in iqs7211_register_tp()
2147 } else if (iqs7211->num_contacts > IQS7211_MAX_CONTACTS) { in iqs7211_register_tp()
2149 iqs7211->num_contacts); 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()
2164 iqs7211->tp_idev = tp_idev; 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()
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()
2208 static int iqs7211_report(struct iqs7211_private *iqs7211) in iqs7211_report() argument
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()
2219 iqs7211->num_contacts * sizeof(*touch_data)); in iqs7211_report()
2233 iqs7211->comms_mode = iqs7211->comms_init; in iqs7211_report()
2235 return iqs7211_init_device(iqs7211); in iqs7211_report()
2247 for (i = 0; i < iqs7211->num_contacts; i++) { 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()
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()
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()
2293 input_report_key(iqs7211->kp_idev, iqs7211->kp_code[i], 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()
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()
2341 struct iqs7211_private *iqs7211 = context; in iqs7211_irq() local
2343 return iqs7211_report(iqs7211) ? IRQ_NONE : IRQ_HANDLED; in iqs7211_irq()
2348 struct iqs7211_private *iqs7211 = dev_get_drvdata(dev); in iqs7211_suspend() local
2349 const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; 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()
2365 enable_irq(gpiod_to_irq(iqs7211->irq_gpio)); in iqs7211_suspend()
2372 struct iqs7211_private *iqs7211 = dev_get_drvdata(dev); in iqs7211_resume() local
2373 const struct iqs7211_dev_desc *dev_desc = iqs7211->dev_desc; in iqs7211_resume()
2376 cpu_to_le16(iqs7211->event_mask), in iqs7211_resume()
2383 disable_irq(gpiod_to_irq(iqs7211->irq_gpio)); 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()
2402 struct iqs7211_private *iqs7211 = dev_get_drvdata(dev); in fw_info_show() local
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()
2418 ATTRIBUTE_GROUPS(iqs7211);
2439 struct iqs7211_private *iqs7211; in iqs7211_probe() local
2445 iqs7211 = devm_kzalloc(&client->dev, sizeof(*iqs7211), GFP_KERNEL); in iqs7211_probe()
2446 if (!iqs7211) in iqs7211_probe()
2449 i2c_set_clientdata(client, iqs7211); 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()
2458 shared_irq = iqs7211->dev_desc->num_ctx == IQS7211_MAX_CTX; 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()
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()
2493 error = iqs7211_start_comms(iqs7211); in iqs7211_probe()
2510 error = iqs7211_parse_reg_grp(iqs7211, reg_grp_node, reg_grp); in iqs7211_probe()
2516 error = iqs7211_register_kp(iqs7211); in iqs7211_probe()
2520 error = iqs7211_register_tp(iqs7211); in iqs7211_probe()
2524 error = iqs7211_init_device(iqs7211); 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()
2537 irq_flags, client->name, iqs7211); in iqs7211_probe()