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