Lines Matching refs:ts

219 static int cyttsp5_read(struct cyttsp5 *ts, u8 *buf, u32 max)
226 error = regmap_bulk_read(ts->regmap, HID_INPUT_REG, temp, sizeof(temp));
238 return regmap_bulk_read(ts->regmap, HID_INPUT_REG, buf, size);
241 static int cyttsp5_write(struct cyttsp5 *ts, unsigned int reg, u8 *data,
263 return regmap_bulk_write(ts->regmap, reg & 0xFF, cmd, size + 1);
277 static void cyttsp5_get_touch_record(struct cyttsp5 *ts,
280 struct cyttsp5_sysinfo *si = &ts->sysinfo;
291 static void cyttsp5_get_mt_touches(struct cyttsp5 *ts,
294 struct cyttsp5_sysinfo *si = &ts->sysinfo;
303 switch (ts->input_buf[2]) {
313 tch_addr = ts->input_buf + offset + (i * TOUCH_REPORT_SIZE);
314 cyttsp5_get_touch_record(ts, tch, tch_addr);
323 input_mt_slot(ts->input, t);
324 input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, true);
328 touchscreen_report_pos(ts->input, &ts->prop,
331 input_report_abs(ts->input, ABS_MT_PRESSURE,
335 input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR,
337 input_report_abs(ts->input, ABS_MT_TOUCH_MINOR,
341 ts->num_prv_rec = num_cur_tch;
346 struct cyttsp5 *ts = dev_get_drvdata(dev);
347 struct cyttsp5_sysinfo *si = &ts->sysinfo;
354 ts->input_buf + 3 + si->tch_hdr.ofs,
362 if (num_cur_tch == 0 && ts->num_prv_rec == 0)
367 cyttsp5_get_mt_touches(ts, &tch, num_cur_tch);
369 input_mt_sync_frame(ts->input);
370 input_sync(ts->input);
377 struct cyttsp5 *ts = dev_get_drvdata(dev);
378 struct cyttsp5_sysinfo *si = &ts->sysinfo;
389 input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, max_x, 0, 0);
390 input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, max_y, 0, 0);
391 input_set_abs_params(ts->input, ABS_MT_PRESSURE, 0, max_p, 0, 0);
393 input_set_abs_params(ts->input, ABS_MT_TOUCH_MAJOR, 0, MAX_AREA, 0, 0);
394 input_set_abs_params(ts->input, ABS_MT_TOUCH_MINOR, 0, MAX_AREA, 0, 0);
396 error = input_mt_init_slots(ts->input, si->tch_abs[CY_TCH_T].max,
401 error = input_register_device(ts->input);
412 struct cyttsp5 *ts = dev_get_drvdata(dev);
413 struct cyttsp5_sysinfo *si = &ts->sysinfo;
427 struct cyttsp5 *ts = dev_get_drvdata(dev);
428 struct cyttsp5_sysinfo *si = &ts->sysinfo;
432 switch (ts->input_buf[2]) {
441 if (ts->input_buf[2] != HID_BTN_REPORT_ID)
447 cur_btn_state = (ts->input_buf[offset] >> (cur_btn * CY_BITS_PER_BTN))
450 input_report_key(ts->input, si->key_code[cur_btn],
452 input_sync(ts->input);
458 static int cyttsp5_validate_cmd_response(struct cyttsp5 *ts, u8 code)
464 size = get_unaligned_le16(&ts->response_buf[0]);
468 report_id = ts->response_buf[HID_OUTPUT_RESPONSE_REPORT_OFFSET];
472 if (ts->response_buf[4] != HID_OUTPUT_BL_SOP) {
473 dev_err(ts->dev, "HID output response, wrong SOP\n");
477 if (ts->response_buf[size - 1] != HID_OUTPUT_BL_EOP) {
478 dev_err(ts->dev, "HID output response, wrong EOP\n");
482 crc = crc_itu_t(0xFFFF, &ts->response_buf[4], size - 7);
483 if (get_unaligned_le16(&ts->response_buf[size - 3]) != crc) {
484 dev_err(ts->dev,
490 status = ts->response_buf[5];
492 dev_err(ts->dev, "HID output response, ERROR:%d\n",
499 command_code = ts->response_buf[HID_OUTPUT_RESPONSE_CMD_OFFSET]
502 dev_err(ts->dev,
513 static void cyttsp5_si_get_btn_data(struct cyttsp5 *ts)
515 struct cyttsp5_sysinfo *si = &ts->sysinfo;
516 unsigned int btns = ts->response_buf[HID_SYSINFO_BTN_OFFSET] &
522 static int cyttsp5_get_sysinfo_regs(struct cyttsp5 *ts)
524 struct cyttsp5_sensing_conf_data *scd = &ts->sysinfo.sensing_conf_data;
527 &ts->response_buf[HID_SYSINFO_SENSING_OFFSET];
529 cyttsp5_si_get_btn_data(ts);
541 static int cyttsp5_hid_output_get_sysinfo(struct cyttsp5 *ts)
552 rc = cyttsp5_write(ts, HID_OUTPUT_REG, cmd,
555 dev_err(ts->dev, "Failed to write command %d", rc);
559 rc = wait_for_completion_interruptible_timeout(&ts->cmd_done,
562 dev_err(ts->dev, "HID output cmd execution timed out\n");
567 rc = cyttsp5_validate_cmd_response(ts, HID_OUTPUT_GET_SYSINFO);
569 dev_err(ts->dev, "Validation of the response failed\n");
573 return cyttsp5_get_sysinfo_regs(ts);
576 static int cyttsp5_power_control(struct cyttsp5 *ts, bool on)
586 rc = cyttsp5_write(ts, HID_COMMAND_REG, cmd, sizeof(cmd));
588 dev_err(ts->dev, "Failed to write power command %d", rc);
592 rc = wait_for_completion_interruptible_timeout(&ts->cmd_done,
595 dev_err(ts->dev, "HID power cmd execution timed out\n");
599 if (ts->response_buf[2] != HID_RESPONSE_REPORT_ID ||
600 (ts->response_buf[3] & 0x03) != state ||
601 (ts->response_buf[4] & 0x0f) != HID_CMD_SET_POWER) {
602 dev_err(ts->dev, "Validation of the %s response failed\n",
610 static int cyttsp5_hid_output_bl_launch_app(struct cyttsp5 *ts)
626 rc = cyttsp5_write(ts, HID_OUTPUT_REG, cmd,
629 dev_err(ts->dev, "Failed to write command %d", rc);
633 rc = wait_for_completion_interruptible_timeout(&ts->cmd_done,
636 dev_err(ts->dev, "HID output cmd execution timed out\n");
641 rc = cyttsp5_validate_cmd_response(ts, HID_OUTPUT_BL_LAUNCH_APP);
643 dev_err(ts->dev, "Validation of the response failed\n");
650 static int cyttsp5_get_hid_descriptor(struct cyttsp5 *ts,
653 struct device *dev = ts->dev;
656 rc = cyttsp5_write(ts, HID_DESC_REG, NULL, 0);
662 rc = wait_for_completion_interruptible_timeout(&ts->cmd_done,
665 dev_err(ts->dev, "HID get descriptor timed out\n");
670 memcpy(desc, ts->response_buf, sizeof(*desc));
698 struct cyttsp5 *ts = handle;
703 error = cyttsp5_read(ts, ts->input_buf, CY_MAX_INPUT);
707 size = get_unaligned_le16(&ts->input_buf[0]);
713 report_id = ts->input_buf[2];
718 cyttsp5_mt_attention(ts->dev);
721 cyttsp5_btn_attention(ts->dev);
724 memcpy(ts->response_buf, ts->input_buf, size);
725 complete(&ts->cmd_done);
729 memcpy(ts->response_buf, ts->input_buf, size);
730 complete(&ts->cmd_done);
736 static int cyttsp5_deassert_int(struct cyttsp5 *ts)
742 error = regmap_bulk_read(ts->regmap, HID_INPUT_REG, buf, sizeof(buf));
753 static int cyttsp5_fill_all_touch(struct cyttsp5 *ts)
755 struct cyttsp5_sysinfo *si = &ts->sysinfo;
775 static int cyttsp5_startup(struct cyttsp5 *ts)
779 error = cyttsp5_deassert_int(ts);
781 dev_err(ts->dev, "Error on deassert int r=%d\n", error);
789 error = cyttsp5_hid_output_bl_launch_app(ts);
791 dev_err(ts->dev, "Error on launch app r=%d\n", error);
795 error = cyttsp5_get_hid_descriptor(ts, &ts->hid_desc);
797 dev_err(ts->dev, "Error on getting HID descriptor r=%d\n", error);
801 error = cyttsp5_fill_all_touch(ts);
803 dev_err(ts->dev, "Error on report descriptor r=%d\n", error);
807 error = cyttsp5_hid_output_get_sysinfo(ts);
809 dev_err(ts->dev, "Error on getting sysinfo r=%d\n", error);
818 struct cyttsp5 *ts = data;
820 regulator_bulk_disable(ARRAY_SIZE(ts->supplies), ts->supplies);
826 struct cyttsp5 *ts;
830 ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL);
831 if (!ts)
835 ts->regmap = regmap;
836 ts->dev = dev;
837 si = &ts->sysinfo;
838 dev_set_drvdata(dev, ts);
840 init_completion(&ts->cmd_done);
843 ts->supplies[0].supply = "vdd";
844 ts->supplies[1].supply = "vddio";
845 error = devm_regulator_bulk_get(dev, ARRAY_SIZE(ts->supplies),
846 ts->supplies);
848 dev_err(ts->dev, "Failed to get regulators, error %d\n", error);
852 error = devm_add_action_or_reset(dev, cyttsp5_cleanup, ts);
856 error = regulator_bulk_enable(ARRAY_SIZE(ts->supplies), ts->supplies);
858 dev_err(ts->dev, "Failed to enable regulators, error %d\n", error);
862 ts->input = devm_input_allocate_device(dev);
863 if (!ts->input) {
868 ts->input->name = "cyttsp5";
869 scnprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(dev));
870 ts->input->phys = ts->phys;
871 input_set_drvdata(ts->input, ts);
874 ts->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
875 if (IS_ERR(ts->reset_gpio)) {
876 error = PTR_ERR(ts->reset_gpio);
880 gpiod_set_value_cansleep(ts->reset_gpio, 0);
886 IRQF_ONESHOT, name, ts);
892 error = cyttsp5_startup(ts);
894 dev_err(ts->dev, "Fail initial startup r=%d\n", error);
900 dev_err(ts->dev, "Error while parsing dts %d\n", error);
904 touchscreen_parse_properties(ts->input, true, &ts->prop);
906 __set_bit(EV_KEY, ts->input->evbit);
908 __set_bit(si->key_code[i], ts->input->keybit);
945 struct cyttsp5 *ts = dev_get_drvdata(dev);
948 cyttsp5_power_control(ts, false);
955 struct cyttsp5 *ts = dev_get_drvdata(dev);
958 cyttsp5_power_control(ts, true);