Lines Matching refs:ts
202 static int cyttsp5_read(struct cyttsp5 *ts, u8 *buf, u32 max) in cyttsp5_read() argument
209 error = regmap_bulk_read(ts->regmap, HID_INPUT_REG, temp, sizeof(temp)); in cyttsp5_read()
221 return regmap_bulk_read(ts->regmap, HID_INPUT_REG, buf, size); in cyttsp5_read()
224 static int cyttsp5_write(struct cyttsp5 *ts, unsigned int reg, u8 *data, in cyttsp5_write() argument
246 return regmap_bulk_write(ts->regmap, reg & 0xFF, cmd, size + 1); in cyttsp5_write()
260 static void cyttsp5_get_touch_record(struct cyttsp5 *ts, in cyttsp5_get_touch_record() argument
263 struct cyttsp5_sysinfo *si = &ts->sysinfo; in cyttsp5_get_touch_record()
274 static void cyttsp5_get_mt_touches(struct cyttsp5 *ts, in cyttsp5_get_mt_touches() argument
277 struct cyttsp5_sysinfo *si = &ts->sysinfo; in cyttsp5_get_mt_touches()
286 switch (ts->input_buf[2]) { in cyttsp5_get_mt_touches()
296 tch_addr = ts->input_buf + offset + (i * TOUCH_REPORT_SIZE); in cyttsp5_get_mt_touches()
297 cyttsp5_get_touch_record(ts, tch, tch_addr); in cyttsp5_get_mt_touches()
306 input_mt_slot(ts->input, t); in cyttsp5_get_mt_touches()
307 input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, true); in cyttsp5_get_mt_touches()
311 touchscreen_report_pos(ts->input, &ts->prop, in cyttsp5_get_mt_touches()
314 input_report_abs(ts->input, ABS_MT_PRESSURE, in cyttsp5_get_mt_touches()
318 input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, in cyttsp5_get_mt_touches()
320 input_report_abs(ts->input, ABS_MT_TOUCH_MINOR, in cyttsp5_get_mt_touches()
324 ts->num_prv_rec = num_cur_tch; in cyttsp5_get_mt_touches()
329 struct cyttsp5 *ts = dev_get_drvdata(dev); in cyttsp5_mt_attention() local
330 struct cyttsp5_sysinfo *si = &ts->sysinfo; in cyttsp5_mt_attention()
337 ts->input_buf + 3 + si->tch_hdr.ofs, in cyttsp5_mt_attention()
345 if (num_cur_tch == 0 && ts->num_prv_rec == 0) in cyttsp5_mt_attention()
350 cyttsp5_get_mt_touches(ts, &tch, num_cur_tch); in cyttsp5_mt_attention()
352 input_mt_sync_frame(ts->input); in cyttsp5_mt_attention()
353 input_sync(ts->input); in cyttsp5_mt_attention()
360 struct cyttsp5 *ts = dev_get_drvdata(dev); in cyttsp5_setup_input_device() local
361 struct cyttsp5_sysinfo *si = &ts->sysinfo; in cyttsp5_setup_input_device()
372 input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, max_x, 0, 0); in cyttsp5_setup_input_device()
373 input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, max_y, 0, 0); in cyttsp5_setup_input_device()
374 input_set_abs_params(ts->input, ABS_MT_PRESSURE, 0, max_p, 0, 0); in cyttsp5_setup_input_device()
376 input_set_abs_params(ts->input, ABS_MT_TOUCH_MAJOR, 0, MAX_AREA, 0, 0); in cyttsp5_setup_input_device()
377 input_set_abs_params(ts->input, ABS_MT_TOUCH_MINOR, 0, MAX_AREA, 0, 0); in cyttsp5_setup_input_device()
379 error = input_mt_init_slots(ts->input, si->tch_abs[CY_TCH_T].max, in cyttsp5_setup_input_device()
384 error = input_register_device(ts->input); in cyttsp5_setup_input_device()
395 struct cyttsp5 *ts = dev_get_drvdata(dev); in cyttsp5_parse_dt_key_code() local
396 struct cyttsp5_sysinfo *si = &ts->sysinfo; in cyttsp5_parse_dt_key_code()
410 struct cyttsp5 *ts = dev_get_drvdata(dev); in cyttsp5_btn_attention() local
411 struct cyttsp5_sysinfo *si = &ts->sysinfo; in cyttsp5_btn_attention()
415 switch (ts->input_buf[2]) { in cyttsp5_btn_attention()
424 if (ts->input_buf[2] != HID_BTN_REPORT_ID) in cyttsp5_btn_attention()
430 cur_btn_state = (ts->input_buf[offset] >> (cur_btn * CY_BITS_PER_BTN)) in cyttsp5_btn_attention()
433 input_report_key(ts->input, si->key_code[cur_btn], in cyttsp5_btn_attention()
435 input_sync(ts->input); in cyttsp5_btn_attention()
441 static int cyttsp5_validate_cmd_response(struct cyttsp5 *ts, u8 code) in cyttsp5_validate_cmd_response() argument
447 size = get_unaligned_le16(&ts->response_buf[0]); in cyttsp5_validate_cmd_response()
451 report_id = ts->response_buf[HID_OUTPUT_RESPONSE_REPORT_OFFSET]; in cyttsp5_validate_cmd_response()
455 if (ts->response_buf[4] != HID_OUTPUT_BL_SOP) { in cyttsp5_validate_cmd_response()
456 dev_err(ts->dev, "HID output response, wrong SOP\n"); in cyttsp5_validate_cmd_response()
460 if (ts->response_buf[size - 1] != HID_OUTPUT_BL_EOP) { in cyttsp5_validate_cmd_response()
461 dev_err(ts->dev, "HID output response, wrong EOP\n"); in cyttsp5_validate_cmd_response()
465 crc = crc_itu_t(0xFFFF, &ts->response_buf[4], size - 7); in cyttsp5_validate_cmd_response()
466 if (get_unaligned_le16(&ts->response_buf[size - 3]) != crc) { in cyttsp5_validate_cmd_response()
467 dev_err(ts->dev, in cyttsp5_validate_cmd_response()
473 status = ts->response_buf[5]; in cyttsp5_validate_cmd_response()
475 dev_err(ts->dev, "HID output response, ERROR:%d\n", in cyttsp5_validate_cmd_response()
482 command_code = ts->response_buf[HID_OUTPUT_RESPONSE_CMD_OFFSET] in cyttsp5_validate_cmd_response()
485 dev_err(ts->dev, in cyttsp5_validate_cmd_response()
496 static void cyttsp5_si_get_btn_data(struct cyttsp5 *ts) in cyttsp5_si_get_btn_data() argument
498 struct cyttsp5_sysinfo *si = &ts->sysinfo; in cyttsp5_si_get_btn_data()
499 unsigned int btns = ts->response_buf[HID_SYSINFO_BTN_OFFSET] & in cyttsp5_si_get_btn_data()
505 static int cyttsp5_get_sysinfo_regs(struct cyttsp5 *ts) in cyttsp5_get_sysinfo_regs() argument
507 struct cyttsp5_sensing_conf_data *scd = &ts->sysinfo.sensing_conf_data; in cyttsp5_get_sysinfo_regs()
510 &ts->response_buf[HID_SYSINFO_SENSING_OFFSET]; in cyttsp5_get_sysinfo_regs()
512 cyttsp5_si_get_btn_data(ts); in cyttsp5_get_sysinfo_regs()
524 static int cyttsp5_hid_output_get_sysinfo(struct cyttsp5 *ts) in cyttsp5_hid_output_get_sysinfo() argument
535 rc = cyttsp5_write(ts, HID_OUTPUT_REG, cmd, in cyttsp5_hid_output_get_sysinfo()
538 dev_err(ts->dev, "Failed to write command %d", rc); in cyttsp5_hid_output_get_sysinfo()
542 rc = wait_for_completion_interruptible_timeout(&ts->cmd_done, in cyttsp5_hid_output_get_sysinfo()
545 dev_err(ts->dev, "HID output cmd execution timed out\n"); in cyttsp5_hid_output_get_sysinfo()
550 rc = cyttsp5_validate_cmd_response(ts, HID_OUTPUT_GET_SYSINFO); in cyttsp5_hid_output_get_sysinfo()
552 dev_err(ts->dev, "Validation of the response failed\n"); in cyttsp5_hid_output_get_sysinfo()
556 return cyttsp5_get_sysinfo_regs(ts); in cyttsp5_hid_output_get_sysinfo()
559 static int cyttsp5_hid_output_bl_launch_app(struct cyttsp5 *ts) in cyttsp5_hid_output_bl_launch_app() argument
575 rc = cyttsp5_write(ts, HID_OUTPUT_REG, cmd, in cyttsp5_hid_output_bl_launch_app()
578 dev_err(ts->dev, "Failed to write command %d", rc); in cyttsp5_hid_output_bl_launch_app()
582 rc = wait_for_completion_interruptible_timeout(&ts->cmd_done, in cyttsp5_hid_output_bl_launch_app()
585 dev_err(ts->dev, "HID output cmd execution timed out\n"); in cyttsp5_hid_output_bl_launch_app()
590 rc = cyttsp5_validate_cmd_response(ts, HID_OUTPUT_BL_LAUNCH_APP); in cyttsp5_hid_output_bl_launch_app()
592 dev_err(ts->dev, "Validation of the response failed\n"); in cyttsp5_hid_output_bl_launch_app()
599 static int cyttsp5_get_hid_descriptor(struct cyttsp5 *ts, in cyttsp5_get_hid_descriptor() argument
602 struct device *dev = ts->dev; in cyttsp5_get_hid_descriptor()
610 rc = cyttsp5_write(ts, HID_DESC_REG, NULL, 0); in cyttsp5_get_hid_descriptor()
616 rc = wait_for_completion_interruptible_timeout(&ts->cmd_done, in cyttsp5_get_hid_descriptor()
619 dev_err(ts->dev, "HID get descriptor timed out\n"); in cyttsp5_get_hid_descriptor()
624 memcpy(desc, ts->response_buf, sizeof(*desc)); in cyttsp5_get_hid_descriptor()
652 struct cyttsp5 *ts = handle; in cyttsp5_handle_irq() local
657 error = cyttsp5_read(ts, ts->input_buf, CY_MAX_INPUT); in cyttsp5_handle_irq()
661 size = get_unaligned_le16(&ts->input_buf[0]); in cyttsp5_handle_irq()
667 report_id = ts->input_buf[2]; in cyttsp5_handle_irq()
672 cyttsp5_mt_attention(ts->dev); in cyttsp5_handle_irq()
675 cyttsp5_btn_attention(ts->dev); in cyttsp5_handle_irq()
679 memcpy(ts->response_buf, ts->input_buf, size); in cyttsp5_handle_irq()
680 complete(&ts->cmd_done); in cyttsp5_handle_irq()
686 static int cyttsp5_deassert_int(struct cyttsp5 *ts) in cyttsp5_deassert_int() argument
692 error = regmap_bulk_read(ts->regmap, HID_INPUT_REG, buf, sizeof(buf)); in cyttsp5_deassert_int()
703 static int cyttsp5_fill_all_touch(struct cyttsp5 *ts) in cyttsp5_fill_all_touch() argument
705 struct cyttsp5_sysinfo *si = &ts->sysinfo; in cyttsp5_fill_all_touch()
725 static int cyttsp5_startup(struct cyttsp5 *ts) in cyttsp5_startup() argument
729 error = cyttsp5_deassert_int(ts); in cyttsp5_startup()
731 dev_err(ts->dev, "Error on deassert int r=%d\n", error); in cyttsp5_startup()
739 error = cyttsp5_hid_output_bl_launch_app(ts); in cyttsp5_startup()
741 dev_err(ts->dev, "Error on launch app r=%d\n", error); in cyttsp5_startup()
745 error = cyttsp5_get_hid_descriptor(ts, &ts->hid_desc); in cyttsp5_startup()
747 dev_err(ts->dev, "Error on getting HID descriptor r=%d\n", error); in cyttsp5_startup()
751 error = cyttsp5_fill_all_touch(ts); in cyttsp5_startup()
753 dev_err(ts->dev, "Error on report descriptor r=%d\n", error); in cyttsp5_startup()
757 error = cyttsp5_hid_output_get_sysinfo(ts); in cyttsp5_startup()
759 dev_err(ts->dev, "Error on getting sysinfo r=%d\n", error); in cyttsp5_startup()
768 struct cyttsp5 *ts = data; in cyttsp5_cleanup() local
770 regulator_disable(ts->vdd); in cyttsp5_cleanup()
776 struct cyttsp5 *ts; in cyttsp5_probe() local
780 ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL); in cyttsp5_probe()
781 if (!ts) in cyttsp5_probe()
785 ts->regmap = regmap; in cyttsp5_probe()
786 ts->dev = dev; in cyttsp5_probe()
787 si = &ts->sysinfo; in cyttsp5_probe()
788 dev_set_drvdata(dev, ts); in cyttsp5_probe()
790 init_completion(&ts->cmd_done); in cyttsp5_probe()
793 ts->vdd = devm_regulator_get(dev, "vdd"); in cyttsp5_probe()
794 if (IS_ERR(ts->vdd)) { in cyttsp5_probe()
795 error = PTR_ERR(ts->vdd); in cyttsp5_probe()
799 error = devm_add_action_or_reset(dev, cyttsp5_cleanup, ts); in cyttsp5_probe()
803 error = regulator_enable(ts->vdd); in cyttsp5_probe()
807 ts->input = devm_input_allocate_device(dev); in cyttsp5_probe()
808 if (!ts->input) { in cyttsp5_probe()
813 ts->input->name = "cyttsp5"; in cyttsp5_probe()
814 scnprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(dev)); in cyttsp5_probe()
815 ts->input->phys = ts->phys; in cyttsp5_probe()
816 input_set_drvdata(ts->input, ts); in cyttsp5_probe()
819 ts->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); in cyttsp5_probe()
820 if (IS_ERR(ts->reset_gpio)) { in cyttsp5_probe()
821 error = PTR_ERR(ts->reset_gpio); in cyttsp5_probe()
825 gpiod_set_value_cansleep(ts->reset_gpio, 0); in cyttsp5_probe()
831 IRQF_ONESHOT, name, ts); in cyttsp5_probe()
837 error = cyttsp5_startup(ts); in cyttsp5_probe()
839 dev_err(ts->dev, "Fail initial startup r=%d\n", error); in cyttsp5_probe()
845 dev_err(ts->dev, "Error while parsing dts %d\n", error); in cyttsp5_probe()
849 touchscreen_parse_properties(ts->input, true, &ts->prop); in cyttsp5_probe()
851 __set_bit(EV_KEY, ts->input->evbit); in cyttsp5_probe()
853 __set_bit(si->key_code[i], ts->input->keybit); in cyttsp5_probe()