Re: [PATCH v2 4/5] ARM: dts: imx6dl: plym2m, prtvt7, victgo: make use of new resistive-adc-touch driver

2022-01-31 Thread Oleksij Rempel
Hi Sam,

On Mon, Jan 31, 2022 at 04:42:06PM +0100, Sam Ravnborg wrote:
> On Mon, Jan 31, 2022 at 11:28:40AM +0100, Oleksij Rempel wrote:
> > The tsc2046 is an ADC used as touchscreen controller. To share as mach
> much
> > code as possible, we should use it as actual ADC + virtual touchscreen
> > controller.
> > With this patch we make use of the new kernel IIO and HID infrastructure.
> > 
> > Signed-off-by: Oleksij Rempel 
> > ---
> >  arch/arm/boot/dts/imx6dl-plym2m.dts | 59 +
> >  arch/arm/boot/dts/imx6dl-prtvt7.dts | 57 +---
> >  arch/arm/boot/dts/imx6dl-victgo.dts | 59 ++---
> >  3 files changed, 132 insertions(+), 43 deletions(-)
> > 
> > diff --git a/arch/arm/boot/dts/imx6dl-plym2m.dts 
> > b/arch/arm/boot/dts/imx6dl-plym2m.dts
> > index 60fe5f14666e..73c7622bfe0f 100644
> > --- a/arch/arm/boot/dts/imx6dl-plym2m.dts
> > +++ b/arch/arm/boot/dts/imx6dl-plym2m.dts
> > @@ -101,6 +101,18 @@ reg_12v0: regulator-12v0 {
> > regulator-min-microvolt = <1200>;
> > regulator-max-microvolt = <1200>;
> > };
> > +
> > +   touchscreen {
> > +   compatible = "resistive-adc-touch";
> > +   io-channels = <_ts 1>, <_ts 3>, <_ts 4>,
> > +  <_ts 5>;
> > +   io-channel-names = "y", "z1", "z2", "x";
> > +   touchscreen-min-pressure = <64687>;
> > +   touchscreen-inverted-x;
> > +   touchscreen-inverted-y;
> > +   touchscreen-x-plate-ohms = <300>;
> > +   touchscreen-y-plate-ohms = <800>;
> > +   };
> >  };
> >  
> >   {
> > @@ -129,26 +141,41 @@  {
> > pinctrl-0 = <_ecspi2>;
> > status = "okay";
> >  
> > -   touchscreen@0 {
> > -   compatible = "ti,tsc2046";
> > +   adc_ts: adc@0 {
> > +   compatible = "ti,tsc2046e-adc";
> > reg = <0>;
> > pinctrl-0 = <_tsc2046>;
> > pinctrl-names ="default";
> > -   spi-max-frequency = <10>;
> > -   interrupts-extended = < 20 IRQ_TYPE_EDGE_FALLING>;
> > -   pendown-gpio = < 20 GPIO_ACTIVE_LOW>;
> > +   spi-max-frequency = <100>;
> > +   interrupts-extended = < 20 IRQ_TYPE_LEVEL_LOW>;
> > +   #io-channel-cells = <1>;
> 
> I quickly skimmed the patch - we seem to loose the pendown-gpio in most
> of the patches - I do not see it replaced.

pendown-gpio is not used by the new driver. It is replace by the IIO
trigger. Please see this comment:
https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/tree/drivers/iio/adc/ti-tsc2046.c?h=testing#n521

Regards,
Oleksij
-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


Re: [PATCH v2 4/5] ARM: dts: imx6dl: plym2m, prtvt7, victgo: make use of new resistive-adc-touch driver

2022-01-31 Thread Sam Ravnborg
On Mon, Jan 31, 2022 at 11:28:40AM +0100, Oleksij Rempel wrote:
> The tsc2046 is an ADC used as touchscreen controller. To share as mach
much
> code as possible, we should use it as actual ADC + virtual touchscreen
> controller.
> With this patch we make use of the new kernel IIO and HID infrastructure.
> 
> Signed-off-by: Oleksij Rempel 
> ---
>  arch/arm/boot/dts/imx6dl-plym2m.dts | 59 +
>  arch/arm/boot/dts/imx6dl-prtvt7.dts | 57 +---
>  arch/arm/boot/dts/imx6dl-victgo.dts | 59 ++---
>  3 files changed, 132 insertions(+), 43 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/imx6dl-plym2m.dts 
> b/arch/arm/boot/dts/imx6dl-plym2m.dts
> index 60fe5f14666e..73c7622bfe0f 100644
> --- a/arch/arm/boot/dts/imx6dl-plym2m.dts
> +++ b/arch/arm/boot/dts/imx6dl-plym2m.dts
> @@ -101,6 +101,18 @@ reg_12v0: regulator-12v0 {
>   regulator-min-microvolt = <1200>;
>   regulator-max-microvolt = <1200>;
>   };
> +
> + touchscreen {
> + compatible = "resistive-adc-touch";
> + io-channels = <_ts 1>, <_ts 3>, <_ts 4>,
> +  <_ts 5>;
> + io-channel-names = "y", "z1", "z2", "x";
> + touchscreen-min-pressure = <64687>;
> + touchscreen-inverted-x;
> + touchscreen-inverted-y;
> + touchscreen-x-plate-ohms = <300>;
> + touchscreen-y-plate-ohms = <800>;
> + };
>  };
>  
>   {
> @@ -129,26 +141,41 @@  {
>   pinctrl-0 = <_ecspi2>;
>   status = "okay";
>  
> - touchscreen@0 {
> - compatible = "ti,tsc2046";
> + adc_ts: adc@0 {
> + compatible = "ti,tsc2046e-adc";
>   reg = <0>;
>   pinctrl-0 = <_tsc2046>;
>   pinctrl-names ="default";
> - spi-max-frequency = <10>;
> - interrupts-extended = < 20 IRQ_TYPE_EDGE_FALLING>;
> - pendown-gpio = < 20 GPIO_ACTIVE_LOW>;
> + spi-max-frequency = <100>;
> + interrupts-extended = < 20 IRQ_TYPE_LEVEL_LOW>;
> + #io-channel-cells = <1>;

I quickly skimmed the patch - we seem to loose the pendown-gpio in most
of the patches - I do not see it replaced.

Sam


[PATCH v2 4/5] ARM: dts: imx6dl: plym2m, prtvt7, victgo: make use of new resistive-adc-touch driver

2022-01-31 Thread Oleksij Rempel
The tsc2046 is an ADC used as touchscreen controller. To share as mach
code as possible, we should use it as actual ADC + virtual touchscreen
controller.
With this patch we make use of the new kernel IIO and HID infrastructure.

Signed-off-by: Oleksij Rempel 
---
 arch/arm/boot/dts/imx6dl-plym2m.dts | 59 +
 arch/arm/boot/dts/imx6dl-prtvt7.dts | 57 +---
 arch/arm/boot/dts/imx6dl-victgo.dts | 59 ++---
 3 files changed, 132 insertions(+), 43 deletions(-)

diff --git a/arch/arm/boot/dts/imx6dl-plym2m.dts 
b/arch/arm/boot/dts/imx6dl-plym2m.dts
index 60fe5f14666e..73c7622bfe0f 100644
--- a/arch/arm/boot/dts/imx6dl-plym2m.dts
+++ b/arch/arm/boot/dts/imx6dl-plym2m.dts
@@ -101,6 +101,18 @@ reg_12v0: regulator-12v0 {
regulator-min-microvolt = <1200>;
regulator-max-microvolt = <1200>;
};
+
+   touchscreen {
+   compatible = "resistive-adc-touch";
+   io-channels = <_ts 1>, <_ts 3>, <_ts 4>,
+  <_ts 5>;
+   io-channel-names = "y", "z1", "z2", "x";
+   touchscreen-min-pressure = <64687>;
+   touchscreen-inverted-x;
+   touchscreen-inverted-y;
+   touchscreen-x-plate-ohms = <300>;
+   touchscreen-y-plate-ohms = <800>;
+   };
 };
 
  {
@@ -129,26 +141,41 @@  {
pinctrl-0 = <_ecspi2>;
status = "okay";
 
-   touchscreen@0 {
-   compatible = "ti,tsc2046";
+   adc_ts: adc@0 {
+   compatible = "ti,tsc2046e-adc";
reg = <0>;
pinctrl-0 = <_tsc2046>;
pinctrl-names ="default";
-   spi-max-frequency = <10>;
-   interrupts-extended = < 20 IRQ_TYPE_EDGE_FALLING>;
-   pendown-gpio = < 20 GPIO_ACTIVE_LOW>;
+   spi-max-frequency = <100>;
+   interrupts-extended = < 20 IRQ_TYPE_LEVEL_LOW>;
+   #io-channel-cells = <1>;
 
-   touchscreen-inverted-x;
-   touchscreen-inverted-y;
-   touchscreen-max-pressure = <4095>;
-
-   ti,vref-delay-usecs = /bits/ 16 <100>;
-   ti,x-plate-ohms = /bits/ 16 <800>;
-   ti,y-plate-ohms = /bits/ 16 <300>;
-   ti,debounce-max = /bits/ 16 <3>;
-   ti,debounce-tol = /bits/ 16 <70>;
-   ti,debounce-rep = /bits/ 16 <3>;
-   wakeup-source;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   channel@1 {
+   reg = <1>;
+   settling-time-us = <700>;
+   oversampling-ratio = <5>;
+   };
+
+   channel@3 {
+   reg = <3>;
+   settling-time-us = <700>;
+   oversampling-ratio = <5>;
+   };
+
+   channel@4 {
+   reg = <4>;
+   settling-time-us = <700>;
+   oversampling-ratio = <5>;
+   };
+
+   channel@5 {
+   reg = <5>;
+   settling-time-us = <700>;
+   oversampling-ratio = <5>;
+   };
};
 };
 
diff --git a/arch/arm/boot/dts/imx6dl-prtvt7.dts 
b/arch/arm/boot/dts/imx6dl-prtvt7.dts
index baaa6ffc4df9..59e0674420a1 100644
--- a/arch/arm/boot/dts/imx6dl-prtvt7.dts
+++ b/arch/arm/boot/dts/imx6dl-prtvt7.dts
@@ -235,6 +235,18 @@ simple-audio-card,codec {
frame-master;
};
};
+
+   touchscreen {
+   compatible = "resistive-adc-touch";
+   io-channels = <_ts 1>, <_ts 3>, <_ts 4>,
+  <_ts 5>;
+   io-channel-names = "y", "z1", "z2", "x";
+   touchscreen-min-pressure = <64687>;
+   touchscreen-inverted-x;
+   touchscreen-inverted-y;
+   touchscreen-x-plate-ohms = <300>;
+   touchscreen-y-plate-ohms = <800>;
+   };
 };
 
  {
@@ -277,22 +289,41 @@  {
pinctrl-0 = <_ecspi2>;
status = "okay";
 
-   touchscreen@0 {
-   compatible = "ti,tsc2046";
+   adc_ts: adc@0 {
+   compatible = "ti,tsc2046e-adc";
reg = <0>;
pinctrl-0 = <_tsc>;
pinctrl-names ="default";
-   spi-max-frequency = <10>;
-   interrupts-extended = < 20 IRQ_TYPE_EDGE_FALLING>;
-   pendown-gpio = < 20 GPIO_ACTIVE_LOW>;
-   touchscreen-max-pressure = <4095>;
-   ti,vref-delay-usecs = /bits/ 16 <100>;
-   ti,x-plate-ohms = /bits/ 16 <800>;
-   ti,y-plate-ohms = /bits/ 16 <300>;
-   ti,debounce-max = /bits/ 16 <3>;
-   ti,debounce-tol = /bits/ 16 <70>;
-   ti,debounce-rep = /bits/ 16