On Wed, Oct 26, 2022 at 6:05 AM Alistair Francis <alistair@xxxxxxxxxxxxx> wrote: > > This is the basic driver for the Cypress TrueTouch Gen5 touchscreen > controllers. This driver supports only the I2C bus but it uses regmap > so SPI support could be added later. > The touchscreen can retrieve some defined zone that are handled as > buttons (according to the hardware). That is why it handles > button and multitouch events. > > Reviewed-by: Maxime Ripard <maxime.ripard@xxxxxxxxxxx> > Signed-off-by: Mylène Josserand <mylene.josserand@xxxxxxxxxxx> > Signed-off-by: Alistair Francis <alistair@xxxxxxxxxxxxx> > Tested-by: Andreas Kemnade <andreas@xxxxxxxxxxxx> # Kobo Clara HD > Tested-by: Peter Geis <pgwipeout@xxxxxxxxx> > --- > drivers/input/touchscreen/Kconfig | 16 + > drivers/input/touchscreen/Makefile | 1 + > drivers/input/touchscreen/cyttsp5.c | 902 ++++++++++++++++++++++++++++ > 3 files changed, 919 insertions(+) > create mode 100644 drivers/input/touchscreen/cyttsp5.c > > + > +static int cyttsp5_hid_output_bl_launch_app(struct cyttsp5 *ts) > +{ > + int rc; > + u8 cmd[HID_OUTPUT_BL_LAUNCH_APP]; > + u16 crc; > + > + put_unaligned_le16(HID_OUTPUT_BL_LAUNCH_APP_SIZE, cmd); > + cmd[2] = HID_BL_OUTPUT_REPORT_ID; > + cmd[3] = 0x0; /* Reserved */ > + cmd[4] = HID_OUTPUT_BL_SOP; > + cmd[5] = HID_OUTPUT_BL_LAUNCH_APP; > + put_unaligned_le16(0x00, &cmd[6]); > + crc = crc_itu_t(0xFFFF, &cmd[4], 4); > + put_unaligned_le16(crc, &cmd[8]); > + cmd[10] = HID_OUTPUT_BL_EOP; > + > + rc = cyttsp5_write(ts, HID_OUTPUT_REG, cmd, > + HID_OUTPUT_BL_LAUNCH_APP_SIZE); > + if (rc) { > + dev_err(ts->dev, "Failed to write command %d", rc); > + return rc; > + } > + > + rc = wait_for_completion_interruptible_timeout(&ts->cmd_done, > + msecs_to_jiffies(CY_HID_OUTPUT_TIMEOUT_MS)); > + if (rc <= 0) { > + dev_err(ts->dev, "HID output cmd execution timed out\n"); > + rc = -ETIMEDOUT; > + return rc; > + } I've been seeing this timeout error somewhat randomly on a Variscite i.MX6 QUAD/DUAL VAR-SOM-MX6 Custom Board based device at startup: [ 2.234089] cyttsp5 2-0024: HID output cmd execution timed out [ 2.239957] cyttsp5 2-0024: Error on launch app r=-110 [ 2.245150] cyttsp5 2-0024: Fail initial startup r=-110 [ 2.257502] cyttsp5: probe of 2-0024 failed with error -110 When it doesn't error I just see this: [ 2.061176] input: cyttsp5 as /devices/platform/soc/2100000.bus/21a8000.i2c/i2c-2/2-0024/input/input0 I'm not sure if this is a driver issue or potentially a device tree issue, the upstream kernel device tree node looks like this: touchscreen@24 { compatible = "cypress,tt21000"; reg = <0x24>; interrupt-parent = <&gpio3>; interrupts = <7 IRQ_TYPE_EDGE_FALLING>; reset-gpios = <&gpio5 13 GPIO_ACTIVE_LOW>; vdd-supply = <®_3p3v>; touchscreen-size-x = <880>; touchscreen-size-y = <1280>; }; Full device tree here: https://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux.git/tree/arch/arm/boot/dts/nxp/imx/imx6q-var-mx6customboard.dts?h=for-next The original vendor device tree node for the downstream kernel looked like this: tsc@0x24 { compatible = "cy,cyttsp5_i2c_adapter"; reg = <0x24>; interrupts = <0x07 0x02>; interrupt-parent = <0x07>; cy,adapter_id = "cyttsp5_i2c_adapter"; cy,core { cy,name = "cyttsp5_core"; cy,irq_gpio = <71>; cy,rst_gpio = <141>; cy,hid_desc_register = <0x01>; /* CY_CORE_FLAG_RESTORE_PARAMETERS */ cy,flags = <4>; /* CY_CORE_EWG_NONE */ cy,easy_wakeup_gesture = <0>; cy,btn_keys-tag = <0>; cy,mt { cy,name = "cyttsp5_mt"; cy,inp_dev_name = "cyttsp5_mt"; /* CY_MT_FLAG_NONE */ cy,flags = <0x00>; cy,abs = /* ABS_MT_POSITION_X, CY_ABS_MIN_X, CY_ABS_MAX_X, 0, 0 */ <0x35 0 880 0 0 /* ABS_MT_POSITION_Y, CY_ABS_MIN_Y, CY_ABS_MAX_Y, 0, 0 */ 0x36 0 1280 0 0 /* ABS_MT_PRESSURE, CY_ABS_MIN_P, CY_ABS_MAX_P, 0, 0 */ 0x3a 0 255 0 0 /* CY_IGNORE_VALUE, CY_ABS_MIN_W, CY_ABS_MAX_W, 0, 0 */ 0xffff 0 255 0 0 /* ABS_MT_TRACKING_ID, CY_ABS_MIN_T, CY_ABS_MAX_T, 0, 0 */ 0x39 0 15 0 0 /* ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0 */ 0x30 0 255 0 0 /* ABS_MT_TOUCH_MINOR, 0, 255, 0, 0 */ 0x31 0 255 0 0 /* ABS_MT_ORIENTATION, -127, 127, 0, 0 */ 0x34 0xffffff81 127 0 0 /* ABS_MT_TOOL_TYPE, 0, MT_TOOL_MAX, 0, 0 */ 0x37 0 1 0 0 /* ABS_MT_DISTANCE, 0, 255, 0, 0 */ 0x3b 0 255 0 0>; }; }; };