mbox series

[v10,0/4] Add support for the Cypress cyttsp5

Message ID 20221026114908.191472-1-alistair@alistair23.me
Headers show
Series Add support for the Cypress cyttsp5 | expand

Message

Alistair Francis Oct. 26, 2022, 11:49 a.m. UTC
This patch series builds on top of [1] and adds support for the cyttsp5
touchscreen controller for the reMarkable 2.

I first tried to add an I2C HID device. Although the cyttsp5 has some HID
looking aspects it is not HID compatible. Just in trying to probe the device
I found:
 - The HID descriptor has extra padding
 - The HID descriptor sets the high bytes of the descriptor length
 - The HID descriptor has extra unrecognised tags
 - The HID reset command doesn't appear to work

I don't think there is a way to use the I2C HID framework with the cyttsp5.
For anyone interested you can see the work here [2]. In that branch though I
can only obtain a HID descriptor, nothing else works without more core
changes.

So instead I rebased the series from [1]. Converted to the new yaml DTS
documentation, added regulator support and fixed a x/y miscalculation bug.

1: https://lwn.net/ml/linux-kernel/20180703094309.18514-1-mylene.josserand@bootlin.com/
2: https://github.com/alistair23/linux/commits/rM2-mainline-cyttsp5-hid

v10:
 - Fix device tree binding errors
 - Add commit message about defcofig cahnges
v9:
 - Fixup kernel robot failures
v8:
 - Rebase and resend
v7:
 - Fix device tree warnings
v6:
 - Use reg for the button properties
v5:
 - Address review comments from v4

Alistair Francis (4):
  Input: Add driver for Cypress Generation 5 touchscreen
  dt-bindings: input: Add Cypress TT21000 touchscreen controller
  ARM: imx_v6_v7_defconfig: Enable the cyttsp5 touchscreen
  ARM: dts: imx7d-remarkable2: Enable the cyttsp5

 .../input/touchscreen/cypress,tt21000.yaml    | 106 ++
 arch/arm/boot/dts/imx7d-remarkable2.dts       | 100 ++
 arch/arm/configs/imx_v6_v7_defconfig          |   1 +
 drivers/input/touchscreen/Kconfig             |  16 +
 drivers/input/touchscreen/Makefile            |   1 +
 drivers/input/touchscreen/cyttsp5.c           | 902 ++++++++++++++++++
 6 files changed, 1126 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/touchscreen/cypress,tt21000.yaml
 create mode 100644 drivers/input/touchscreen/cyttsp5.c

Comments

Dmitry Torokhov Oct. 31, 2022, 11:49 p.m. UTC | #1
On Wed, Oct 26, 2022 at 09:49:06PM +1000, Alistair Francis wrote:
> Add the Cypress TrueTouch Generation 5 touchscreen device tree bindings
> documentation. It can use I2C or SPI bus.
> This touchscreen can handle some defined zone that are designed and
> sent as button. To be able to customize the keycode sent, the
> "linux,code" property in a "button" sub-node can be used.
> 
> Signed-off-by: Alistair Francis <alistair@alistair23.me>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> Reviewed-by: Rob Herring <robh@kernel.org>

Applied, thank you.
Dmitry Torokhov Oct. 31, 2022, 11:52 p.m. UTC | #2
On Wed, Oct 26, 2022 at 09:49:05PM +1000, Alistair Francis 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@bootlin.com>
> Signed-off-by: Mylène Josserand <mylene.josserand@bootlin.com>
> Signed-off-by: Alistair Francis <alistair@alistair23.me>
> Tested-by: Andreas Kemnade <andreas@kemnade.info> # Kobo Clara HD
> Tested-by: Peter Geis <pgwipeout@gmail.com>

While I wish we did not have to parse what is essentially HID data
ourselves and basically repeated what i2c-hid does, I understand that
the firmware is not exactly i2c-hid compatible...

Applied, thank you.
Rob Herring Nov. 1, 2022, 11:50 a.m. UTC | #3
On Mon, Oct 31, 2022 at 6:49 PM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
>
> On Wed, Oct 26, 2022 at 09:49:06PM +1000, Alistair Francis wrote:
> > Add the Cypress TrueTouch Generation 5 touchscreen device tree bindings
> > documentation. It can use I2C or SPI bus.
> > This touchscreen can handle some defined zone that are designed and
> > sent as button. To be able to customize the keycode sent, the
> > "linux,code" property in a "button" sub-node can be used.
> >
> > Signed-off-by: Alistair Francis <alistair@alistair23.me>
> > Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> > Reviewed-by: Rob Herring <robh@kernel.org>
>
> Applied, thank you.

It looks like you applied v8, not this version. linux-next now has a warning:

/builds/robherring/linux-dt/Documentation/devicetree/bindings/input/touchscreen/cypress,tt21000.example.dtb:
touchscreen@24: Unevaluated properties are not allowed
('#address-cells', '#size-cells' were unexpected)
        From schema:
/builds/robherring/linux-dt/Documentation/devicetree/bindings/input/touchscreen/cypress,tt21000.yaml

>
> --
> Dmitry
Dmitry Torokhov Nov. 1, 2022, 3 p.m. UTC | #4
On Tue, Nov 01, 2022 at 06:50:23AM -0500, Rob Herring wrote:
> On Mon, Oct 31, 2022 at 6:49 PM Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> >
> > On Wed, Oct 26, 2022 at 09:49:06PM +1000, Alistair Francis wrote:
> > > Add the Cypress TrueTouch Generation 5 touchscreen device tree bindings
> > > documentation. It can use I2C or SPI bus.
> > > This touchscreen can handle some defined zone that are designed and
> > > sent as button. To be able to customize the keycode sent, the
> > > "linux,code" property in a "button" sub-node can be used.
> > >
> > > Signed-off-by: Alistair Francis <alistair@alistair23.me>
> > > Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> > > Reviewed-by: Rob Herring <robh@kernel.org>
> >
> > Applied, thank you.
> 
> It looks like you applied v8, not this version. linux-next now has a warning:
> 
> /builds/robherring/linux-dt/Documentation/devicetree/bindings/input/touchscreen/cypress,tt21000.example.dtb:
> touchscreen@24: Unevaluated properties are not allowed
> ('#address-cells', '#size-cells' were unexpected)
>         From schema:
> /builds/robherring/linux-dt/Documentation/devicetree/bindings/input/touchscreen/cypress,tt21000.yaml

Oops, should be fixed now.
Shawn Guo Nov. 11, 2022, 2:29 a.m. UTC | #5
On Wed, Oct 26, 2022 at 09:49:08PM +1000, Alistair Francis wrote:
> Add support for the cyttsp5 touchscreen controller for the reMarkable 2.
> 
> Signed-off-by: Alistair Francis <alistair@alistair23.me>
> ---
>  arch/arm/boot/dts/imx7d-remarkable2.dts | 100 ++++++++++++++++++++++++
>  1 file changed, 100 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts b/arch/arm/boot/dts/imx7d-remarkable2.dts
> index a2a91bfdd98e..fea480af8e48 100644
> --- a/arch/arm/boot/dts/imx7d-remarkable2.dts
> +++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
> @@ -8,6 +8,7 @@
>  /dts-v1/;
>  
>  #include "imx7d.dtsi"
> +#include <dt-bindings/input/linux-event-codes.h>
>  
>  / {
>  	model = "reMarkable 2.0";
> @@ -47,6 +48,18 @@ reg_digitizer: regulator-digitizer {
>  		startup-delay-us = <100000>; /* 100 ms */
>  	};
>  
> +	reg_touch: regulator-touch {
> +		compatible = "regulator-fixed";
> +		regulator-name = "VDD_3V3_TOUCH";
> +		regulator-min-microvolt = <3300000>;
> +		regulator-max-microvolt = <3300000>;
> +		pinctrl-names = "default", "sleep";
> +		pinctrl-0 = <&pinctrl_touch_reg>;
> +		pinctrl-1 = <&pinctrl_touch_reg>;
> +		gpio = <&gpio1 11 GPIO_ACTIVE_HIGH>;
> +		enable-active-high;
> +	};
> +
>  	wifi_pwrseq: wifi_pwrseq {
>  		compatible = "mmc-pwrseq-simple";
>  		pinctrl-names = "default";
> @@ -84,6 +97,70 @@ wacom_digitizer: digitizer@9 {
>  	};
>  };
>  
> +&i2c3 {
> +	clock-frequency = <100000>;
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&pinctrl_i2c3>;
> +	status = "okay";
> +
> +	tsc@24 {

`touchscreen` for node name?

> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +

Unnecessary newline.

> +		compatible = "cypress,tt21000";

We idiomatically begin property list with compatible.

> +		reg = <0x24>;
> +

Unnecessary newline.

Shawn

> +		pinctrl-names = "default";
> +		pinctrl-0 = <&pinctrl_touch>;
> +		interrupt-parent = <&gpio1>;
> +		interrupts = <14 IRQ_TYPE_EDGE_FALLING>;
> +		reset-gpios = <&gpio1 13 GPIO_ACTIVE_LOW>;
> +		vdd-supply = <&reg_touch>;
> +		touchscreen-size-x = <880>;
> +		touchscreen-size-y = <1280>;
> +
> +		button@0 {
> +			reg = <0>;
> +			linux,keycodes = <KEY_HOMEPAGE>;
> +		};
> +
> +		button@1 {
> +			reg = <1>;
> +			linux,keycodes = <KEY_MENU>;
> +		};
> +
> +		button@2 {
> +			reg = <2>;
> +			linux,keycodes = <KEY_BACK>;
> +		};
> +
> +		button@3 {
> +			reg = <3>;
> +			linux,keycodes = <KEY_SEARCH>;
> +		};
> +
> +		button@4 {
> +			reg = <4>;
> +			linux,keycodes = <KEY_VOLUMEDOWN>;
> +		};
> +
> +		button@5 {
> +			reg = <5>;
> +			linux,keycodes = <KEY_VOLUMEUP>;
> +		};
> +
> +		button@6 {
> +			reg = <6>;
> +			linux,keycodes = <KEY_CAMERA>;
> +		};
> +
> +		button@7 {
> +			reg = <7>;
> +			linux,keycodes = <KEY_POWER>;
> +		};
> +	};
> +};
> +
>  &snvs_pwrkey {
>  	status = "okay";
>  };
> @@ -177,6 +254,15 @@ MX7D_PAD_SAI1_TX_BCLK__GPIO6_IO13	0x14
>  		>;
>  	};
>  
> +	pinctrl_touch: touchgrp {
> +		fsl,pins = <
> +			/* CYTTSP interrupt */
> +			MX7D_PAD_GPIO1_IO14__GPIO1_IO14		0x54
> +			/* CYTTSP reset */
> +			MX7D_PAD_GPIO1_IO13__GPIO1_IO13		0x04
> +		>;
> +	};
> +
>  	pinctrl_i2c1: i2c1grp {
>  		fsl,pins = <
>  			MX7D_PAD_I2C1_SDA__I2C1_SDA		0x4000007f
> @@ -184,6 +270,20 @@ MX7D_PAD_I2C1_SCL__I2C1_SCL		0x4000007f
>  		>;
>  	};
>  
> +	pinctrl_i2c3: i2c3grp {
> +		fsl,pins = <
> +			MX7D_PAD_I2C3_SDA__I2C3_SDA		0x4000007f
> +			MX7D_PAD_I2C3_SCL__I2C3_SCL		0x4000007f
> +		>;
> +	};
> +
> +	pinctrl_touch_reg: touchreggrp {
> +		fsl,pins = <
> +			/* TOUCH_PWR_EN */
> +			MX7D_PAD_GPIO1_IO11__GPIO1_IO11		0x14
> +		>;
> +	};
> +
>  	pinctrl_uart1: uart1grp {
>  		fsl,pins = <
>  			MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX	0x79
> -- 
> 2.37.3
>