linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8 v3] Update CYTTSP driver
@ 2021-04-08 13:11 Linus Walleij
  2021-04-08 13:11 ` [PATCH 1/8 v3] Input: cyttsp - Convert bindings to YAML and extend Linus Walleij
                   ` (7 more replies)
  0 siblings, 8 replies; 15+ messages in thread
From: Linus Walleij @ 2021-04-08 13:11 UTC (permalink / raw)
  To: Ferruh Yigit, Dmitry Torokhov, Javier Martinez Canillas
  Cc: Henrik Rydberg, linux-input, Linus Walleij

The bump from v1 to v3 in this series just reflects that
I follow the numbering of the YAML conversion patch so
it is easy for the maintainer to see what is the latest
version of the whole CYTTSP patch set. (This contains all
applicable CYTTSP patches for now.)

Linus Walleij (8):
  Input: cyttsp - Convert bindings to YAML and extend
  Input: cyttsp - Probe from compatibles
  Input: cyttsp - Obtain regulators
  Input: cyttsp - Error message on boot mode exit error
  Input: cyttsp - Reduce reset pulse timings
  Input: cyttsp - Drop the phys path
  Input: cyttsp - Set abs params for ABS_MT_TOUCH_MAJOR
  Input: cyttsp - Flag the device properly

 .../input/touchscreen/cypress,cy8ctma340.yaml | 149 ++++++++++++++++++
 .../bindings/input/touchscreen/cyttsp.txt     |  93 -----------
 drivers/input/touchscreen/cyttsp_core.c       |  52 +++++-
 drivers/input/touchscreen/cyttsp_core.h       |   3 +-
 drivers/input/touchscreen/cyttsp_i2c.c        |   8 +
 drivers/input/touchscreen/cyttsp_spi.c        |   8 +
 6 files changed, 211 insertions(+), 102 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/input/touchscreen/cypress,cy8ctma340.yaml
 delete mode 100644 Documentation/devicetree/bindings/input/touchscreen/cyttsp.txt

-- 
2.29.2


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/8 v3] Input: cyttsp - Convert bindings to YAML and extend
  2021-04-08 13:11 [PATCH 0/8 v3] Update CYTTSP driver Linus Walleij
@ 2021-04-08 13:11 ` Linus Walleij
  2021-04-10  7:44   ` Dmitry Torokhov
  2021-04-08 13:11 ` [PATCH 2/8 v3] Input: cyttsp - Probe from compatibles Linus Walleij
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Linus Walleij @ 2021-04-08 13:11 UTC (permalink / raw)
  To: Ferruh Yigit, Dmitry Torokhov, Javier Martinez Canillas
  Cc: Henrik Rydberg, linux-input, Linus Walleij, devicetree, Rob Herring

This converts the CYTTSP "Cypress TrueTouch Standard Product"
to YAML bindings and fixes and adds some things in the process:

- Rename the bindings file to cypress,cy8ctma340 after the main
  product in the series.
- Add proper compatibles for the two known products:
  CY8CTMA340 and CY8CTST341.
- Deprecate "cypress,cyttsp-spi" and "cypress,cyttsp-i2c"
  because device compatibles should be named after the
  hardware and not after which bus they are connected to.
  The topology implicitly tells us which bus it is and what
  interface to used.
- Add VCPIN and VDD supplies, these are present just like
  on the CY8CTMA140.

Cc: devicetree@vger.kernel.org
Cc: Ferruh Yigit <fery@cypress.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Javier Martinez Canillas <javier@dowhile0.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v2->v3:
- Collect Robs and Javiers Review tags.
- Use the right mail address for Javier.
- Include in the patch series with the rest of the CYTTSP
  fixes.
ChangeLog v1->v2:
- Use minItems and maxItems directly without -items
- Drop u32 type from all properties ending with "-ms"
  that thus have implicit types.
- Add maintiner to Cc.

Patch to add the new compatibles to the Linux driver is sent
separately.
---
 .../input/touchscreen/cypress,cy8ctma340.yaml | 149 ++++++++++++++++++
 .../bindings/input/touchscreen/cyttsp.txt     |  93 -----------
 2 files changed, 149 insertions(+), 93 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/input/touchscreen/cypress,cy8ctma340.yaml
 delete mode 100644 Documentation/devicetree/bindings/input/touchscreen/cyttsp.txt

diff --git a/Documentation/devicetree/bindings/input/touchscreen/cypress,cy8ctma340.yaml b/Documentation/devicetree/bindings/input/touchscreen/cypress,cy8ctma340.yaml
new file mode 100644
index 000000000000..29eb0b7ebe6a
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/cypress,cy8ctma340.yaml
@@ -0,0 +1,149 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/touchscreen/cypress,cy8ctma340.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Cypress CY8CTMA340 series touchscreen controller bindings
+
+description: The Cypress CY8CTMA340 series (also known as "CYTTSP" after
+  the marketing name Cypress TrueTouch Standard Product) touchscreens can
+  be connected to either I2C or SPI buses.
+
+maintainers:
+  - Javier Martinez Canillas <javier@dowhile0.org>
+  - Linus Walleij <linus.walleij@linaro.org>
+
+allOf:
+  - $ref: touchscreen.yaml#
+
+properties:
+  $nodename:
+    pattern: "^touchscreen(@.*)?$"
+
+  compatible:
+    oneOf:
+      - const: cypress,cy8ctma340
+      - const: cypress,cy8ctst341
+      - const: cypress,cyttsp-spi
+        description: Legacy compatible for SPI connected CY8CTMA340
+        deprecated: true
+      - const: cypress,cyttsp-i2c
+        description: Legacy compatible for I2C connected CY8CTMA340
+        deprecated: true
+
+  reg:
+    description: I2C address when used on the I2C bus, or the SPI chip
+      select index when used on the SPI bus
+
+  clock-frequency:
+    description: I2C client clock frequency, defined for host when using
+      the device on the I2C bus
+    minimum: 0
+    maximum: 400000
+
+  spi-max-frequency:
+    description: SPI clock frequency, defined for host, defined when using
+      the device on the SPI bus. The throughput is maximum 2 Mbps so the
+      typical value is 2000000, if higher rates are used the total throughput
+      needs to be restricted to 2 Mbps.
+    minimum: 0
+    maximum: 6000000
+
+  interrupts:
+    description: Interrupt to host, must be flagged as
+      IRQ_TYPE_EDGE_FALLING.
+    maxItems: 1
+
+  vcpin-supply:
+    description: Analog power supply regulator on VCPIN pin
+
+  vdd-supply:
+    description: Digital power supply regulator on VDD pin
+
+  reset-gpios:
+    description: Reset line for the touchscreen, should be tagged
+      as GPIO_ACTIVE_LOW
+
+  bootloader-key:
+    description: the 8-byte bootloader key that is required to switch
+      the chip from bootloader mode (default mode) to application mode
+    $ref: /schemas/types.yaml#/definitions/uint8-array
+    minItems: 8
+    maxItems: 8
+
+  touchscreen-size-x: true
+  touchscreen-size-y: true
+  touchscreen-fuzz-x: true
+  touchscreen-fuzz-y: true
+
+  active-distance:
+    description: the distance in pixels beyond which a touch must move
+      before movement is detected and reported by the device
+    $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 0
+    maximum: 15
+
+  active-interval-ms:
+    description: the minimum period in ms between consecutive
+      scanning/processing cycles when the chip is in active mode
+    minimum: 0
+    maximum: 255
+
+  lowpower-interval-ms:
+    description: the minimum period in ms between consecutive
+      scanning/processing cycles when the chip is in low-power mode
+    minimum: 0
+    maximum: 2550
+
+  touch-timeout-ms:
+    description: minimum time in ms spent in the active power state while no
+      touches are detected before entering low-power mode
+    minimum: 0
+    maximum: 2550
+
+  use-handshake:
+    description: enable register-based handshake (boolean). This should only
+      be used if the chip is configured to use 'blocking communication with
+      timeout' (in this case the device generates an interrupt at the end of
+      every scanning/processing cycle)
+    $ref: /schemas/types.yaml#/definitions/flag
+
+additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - bootloader-key
+  - touchscreen-size-x
+  - touchscreen-size-y
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/gpio/gpio.h>
+    spi {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      num-cs = <1>;
+      cs-gpios = <&gpio 2 GPIO_ACTIVE_HIGH>;
+
+      touchscreen@0 {
+        compatible = "cypress,cy8ctma340";
+        reg = <0>;
+        interrupt-parent = <&gpio>;
+        interrupts = <20 IRQ_TYPE_EDGE_FALLING>;
+        reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
+        vdd-supply = <&ldo_aux1_reg>;
+        vcpin-supply = <&ldo_aux2_reg>;
+        bootloader-key = /bits/ 8 <0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07>;
+        touchscreen-size-x = <480>;
+        touchscreen-size-y = <800>;
+        active-interval-ms = <0>;
+        touch-timeout-ms = <255>;
+        lowpower-interval-ms = <10>;
+      };
+    };
+
+...
diff --git a/Documentation/devicetree/bindings/input/touchscreen/cyttsp.txt b/Documentation/devicetree/bindings/input/touchscreen/cyttsp.txt
deleted file mode 100644
index 6ee274aa8b03..000000000000
--- a/Documentation/devicetree/bindings/input/touchscreen/cyttsp.txt
+++ /dev/null
@@ -1,93 +0,0 @@
-* Cypress cyttsp touchscreen controller
-
-Required properties:
- - compatible		: must be "cypress,cyttsp-i2c" or "cypress,cyttsp-spi"
- - reg			: Device I2C address or SPI chip select number
- - spi-max-frequency	: Maximum SPI clocking speed of the device (for cyttsp-spi)
- - interrupts		: (gpio) interrupt to which the chip is connected
-			  (see interrupt binding[0]).
- - bootloader-key	: the 8-byte bootloader key that is required to switch
-			  the chip from bootloader mode (default mode) to
-			  application mode.
-			  This property has to be specified as an array of 8
-			  '/bits/ 8' values.
-
-Optional properties:
- - reset-gpios		: the reset gpio the chip is connected to
-			  (see GPIO binding[1] for more details).
- - touchscreen-size-x	: horizontal resolution of touchscreen (in pixels)
- - touchscreen-size-y	: vertical resolution of touchscreen (in pixels)
- - touchscreen-fuzz-x	: horizontal noise value of the absolute input device
-			  (in pixels)
- - touchscreen-fuzz-y	: vertical noise value of the absolute input device
-			  (in pixels)
- - active-distance	: the distance in pixels beyond which a touch must move
-			  before movement is detected and reported by the device.
-			  Valid values: 0-15.
- - active-interval-ms	: the minimum period in ms between consecutive
-			  scanning/processing cycles when the chip is in active mode.
-			  Valid values: 0-255.
- - lowpower-interval-ms	: the minimum period in ms between consecutive
-			  scanning/processing cycles when the chip is in low-power mode.
-			  Valid values: 0-2550
- - touch-timeout-ms	: minimum time in ms spent in the active power state while no
-			  touches are detected before entering low-power mode.
-			  Valid values: 0-2550
- - use-handshake	: enable register-based handshake (boolean). This should
-			  only be used if the chip is configured to use 'blocking
-			  communication with timeout' (in this case the device
-			  generates an interrupt at the end of every
-			  scanning/processing cycle).
-
-[0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
-[1]: Documentation/devicetree/bindings/gpio/gpio.txt
-
-Example:
-	&i2c1 {
-		/* ... */
-		cyttsp@a {
-			compatible = "cypress,cyttsp-i2c";
-			reg = <0xa>;
-			interrupt-parent = <&gpio0>;
-			interrupts = <28 0>;
-			reset-gpios = <&gpio3 4 GPIO_ACTIVE_LOW>;
-
-			touchscreen-size-x = <800>;
-			touchscreen-size-y = <480>;
-			touchscreen-fuzz-x = <4>;
-			touchscreen-fuzz-y = <7>;
-
-			bootloader-key = /bits/ 8 <0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08>;
-			active-distance = <8>;
-			active-interval-ms = <0>;
-			lowpower-interval-ms = <200>;
-			touch-timeout-ms = <100>;
-		};
-
-		/* ... */
-	};
-
-	&mcspi1 {
-		/* ... */
-		cyttsp@0 {
-			compatible = "cypress,cyttsp-spi";
-			spi-max-frequency = <6000000>;
-			reg = <0>;
-			interrupt-parent = <&gpio0>;
-			interrupts = <28 0>;
-			reset-gpios = <&gpio3 4 GPIO_ACTIVE_LOW>;
-
-			touchscreen-size-x = <800>;
-			touchscreen-size-y = <480>;
-			touchscreen-fuzz-x = <4>;
-			touchscreen-fuzz-y = <7>;
-
-			bootloader-key = /bits/ 8 <0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08>;
-			active-distance = <8>;
-			active-interval-ms = <0>;
-			lowpower-interval-ms = <200>;
-			touch-timeout-ms = <100>;
-		};
-
-		/* ... */
-	};
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/8 v3] Input: cyttsp - Probe from compatibles
  2021-04-08 13:11 [PATCH 0/8 v3] Update CYTTSP driver Linus Walleij
  2021-04-08 13:11 ` [PATCH 1/8 v3] Input: cyttsp - Convert bindings to YAML and extend Linus Walleij
@ 2021-04-08 13:11 ` Linus Walleij
  2021-04-08 13:11 ` [PATCH 3/8 v3] Input: cyttsp - Obtain regulators Linus Walleij
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Linus Walleij @ 2021-04-08 13:11 UTC (permalink / raw)
  To: Ferruh Yigit, Dmitry Torokhov, Javier Martinez Canillas
  Cc: Henrik Rydberg, linux-input, Linus Walleij

The driver (both SPI and I2C interface) should probe from
the compatible strings, cypress,cy8ctma340 etc when using
device tree, not as now, where it is probing implicitly from
the I2C/SPI node name "cypress,cyttsp-i2c" etc.

Reviewed-by: Javier Martinez Canillas <javier@dowhile0.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v3:
- Add MODULE_DEVICE_TABLE() for both sets of compatible
  strings.
- Collect Javiers review tag.
---
 drivers/input/touchscreen/cyttsp_i2c.c | 8 ++++++++
 drivers/input/touchscreen/cyttsp_spi.c | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/drivers/input/touchscreen/cyttsp_i2c.c b/drivers/input/touchscreen/cyttsp_i2c.c
index 061debf64a2b..0a09f07bc23a 100644
--- a/drivers/input/touchscreen/cyttsp_i2c.c
+++ b/drivers/input/touchscreen/cyttsp_i2c.c
@@ -52,10 +52,18 @@ static const struct i2c_device_id cyttsp_i2c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, cyttsp_i2c_id);
 
+static const struct of_device_id cyttsp_of_i2c_match[] = {
+	{ .compatible = "cypress,cy8ctma340", },
+	{ .compatible = "cypress,cy8ctst341", },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, cyttsp_of_i2c_match);
+
 static struct i2c_driver cyttsp_i2c_driver = {
 	.driver = {
 		.name	= CY_I2C_NAME,
 		.pm	= &cyttsp_pm_ops,
+		.of_match_table = cyttsp_of_i2c_match,
 	},
 	.probe		= cyttsp_i2c_probe,
 	.id_table	= cyttsp_i2c_id,
diff --git a/drivers/input/touchscreen/cyttsp_spi.c b/drivers/input/touchscreen/cyttsp_spi.c
index 54e410921d53..8715e5354d79 100644
--- a/drivers/input/touchscreen/cyttsp_spi.c
+++ b/drivers/input/touchscreen/cyttsp_spi.c
@@ -160,10 +160,18 @@ static int cyttsp_spi_probe(struct spi_device *spi)
 	return 0;
 }
 
+static const struct of_device_id cyttsp_of_spi_match[] = {
+	{ .compatible = "cypress,cy8ctma340", },
+	{ .compatible = "cypress,cy8ctst341", },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, cyttsp_of_spi_match);
+
 static struct spi_driver cyttsp_spi_driver = {
 	.driver = {
 		.name	= CY_SPI_NAME,
 		.pm	= &cyttsp_pm_ops,
+		.of_match_table = cyttsp_of_spi_match,
 	},
 	.probe  = cyttsp_spi_probe,
 };
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3/8 v3] Input: cyttsp - Obtain regulators
  2021-04-08 13:11 [PATCH 0/8 v3] Update CYTTSP driver Linus Walleij
  2021-04-08 13:11 ` [PATCH 1/8 v3] Input: cyttsp - Convert bindings to YAML and extend Linus Walleij
  2021-04-08 13:11 ` [PATCH 2/8 v3] Input: cyttsp - Probe from compatibles Linus Walleij
@ 2021-04-08 13:11 ` Linus Walleij
  2021-04-08 13:11 ` [PATCH 4/8 v3] Input: cyttsp - Error message on boot mode exit error Linus Walleij
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Linus Walleij @ 2021-04-08 13:11 UTC (permalink / raw)
  To: Ferruh Yigit, Dmitry Torokhov, Javier Martinez Canillas
  Cc: Henrik Rydberg, linux-input, Linus Walleij

The CYTTSP TMA340 chips have two supplies: VCPIN and
VDD for analog and digital voltage respectively.
Add some minimal code to obtain and enable these
regulators if need be.

Reviewed-by: Javier Martinez Canillas <javier@dowhile0.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v3:
- Collect Javier's reviewed-by.
---
 drivers/input/touchscreen/cyttsp_core.c | 30 +++++++++++++++++++++++--
 drivers/input/touchscreen/cyttsp_core.h |  2 ++
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c
index b9772192b5ea..a19d7cce95ca 100644
--- a/drivers/input/touchscreen/cyttsp_core.c
+++ b/drivers/input/touchscreen/cyttsp_core.c
@@ -22,6 +22,7 @@
 #include <linux/slab.h>
 #include <linux/property.h>
 #include <linux/gpio/consumer.h>
+#include <linux/regulator/consumer.h>
 
 #include "cyttsp_core.h"
 
@@ -621,6 +622,19 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
 	ts->bus_ops = bus_ops;
 	ts->irq = irq;
 
+	/*
+	 * VCPIN is the analog voltage supply
+	 * VDD is the digital voltage supply
+	 */
+	ts->regulators[0].supply = "vcpin";
+	ts->regulators[1].supply = "vdd";
+	error = devm_regulator_bulk_get(dev, ARRAY_SIZE(ts->regulators),
+					ts->regulators);
+	if (error) {
+		dev_err(dev, "Failed to get regulators: %d\n", error);
+		return ERR_PTR(error);
+	}
+
 	ts->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
 	if (IS_ERR(ts->reset_gpio)) {
 		error = PTR_ERR(ts->reset_gpio);
@@ -666,20 +680,32 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
 
 	disable_irq(ts->irq);
 
+	error = regulator_bulk_enable(ARRAY_SIZE(ts->regulators),
+				      ts->regulators);
+	if (error) {
+		dev_err(dev, "Cannot enable regulators: %d\n", error);
+		return ERR_PTR(error);
+	}
+
 	cyttsp_hard_reset(ts);
 
 	error = cyttsp_power_on(ts);
 	if (error)
-		return ERR_PTR(error);
+		goto err_dis_reg;
 
 	error = input_register_device(input_dev);
 	if (error) {
 		dev_err(ts->dev, "failed to register input device: %d\n",
 			error);
-		return ERR_PTR(error);
+		goto err_dis_reg;
 	}
 
 	return ts;
+
+err_dis_reg:
+	regulator_bulk_disable(ARRAY_SIZE(ts->regulators),
+			       ts->regulators);
+	return ERR_PTR(error);
 }
 EXPORT_SYMBOL_GPL(cyttsp_probe);
 
diff --git a/drivers/input/touchscreen/cyttsp_core.h b/drivers/input/touchscreen/cyttsp_core.h
index 8c651336ac12..c102a094e888 100644
--- a/drivers/input/touchscreen/cyttsp_core.h
+++ b/drivers/input/touchscreen/cyttsp_core.h
@@ -23,6 +23,7 @@
 #include <linux/types.h>
 #include <linux/device.h>
 #include <linux/input/cyttsp.h>
+#include <linux/regulator/consumer.h>
 
 #define CY_NUM_RETRY		16 /* max number of retries for read ops */
 
@@ -123,6 +124,7 @@ struct cyttsp {
 	enum cyttsp_state state;
 	bool suspended;
 
+	struct regulator_bulk_data regulators[2];
 	struct gpio_desc *reset_gpio;
 	bool use_hndshk;
 	u8 act_dist;
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 4/8 v3] Input: cyttsp - Error message on boot mode exit error
  2021-04-08 13:11 [PATCH 0/8 v3] Update CYTTSP driver Linus Walleij
                   ` (2 preceding siblings ...)
  2021-04-08 13:11 ` [PATCH 3/8 v3] Input: cyttsp - Obtain regulators Linus Walleij
@ 2021-04-08 13:11 ` Linus Walleij
  2021-04-10  7:31   ` Dmitry Torokhov
  2021-04-08 13:11 ` [PATCH 5/8 v3] Input: cyttsp - Reduce reset pulse timings Linus Walleij
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Linus Walleij @ 2021-04-08 13:11 UTC (permalink / raw)
  To: Ferruh Yigit, Dmitry Torokhov, Javier Martinez Canillas
  Cc: Henrik Rydberg, linux-input, Linus Walleij

Provide a proper error message when attempting to exit
boot loader mode and failing, which is something that
happened to me.

Reviewed-by: Javier Martinez Canillas <javier@dowhile0.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v3:
- Collect Javier's Reviewed-by
---
 drivers/input/touchscreen/cyttsp_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c
index a19d7cce95ca..91f8f38b3f06 100644
--- a/drivers/input/touchscreen/cyttsp_core.c
+++ b/drivers/input/touchscreen/cyttsp_core.c
@@ -410,8 +410,10 @@ static int cyttsp_power_on(struct cyttsp *ts)
 	if (GET_BOOTLOADERMODE(ts->bl_data.bl_status) &&
 	    IS_VALID_APP(ts->bl_data.bl_status)) {
 		error = cyttsp_exit_bl_mode(ts);
-		if (error)
+		if (error) {
+			dev_err(ts->dev, "failed to exit bootloader mode\n");
 			return error;
+		}
 	}
 
 	if (GET_HSTMODE(ts->bl_data.bl_file) != CY_OPERATE_MODE ||
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 5/8 v3] Input: cyttsp - Reduce reset pulse timings
  2021-04-08 13:11 [PATCH 0/8 v3] Update CYTTSP driver Linus Walleij
                   ` (3 preceding siblings ...)
  2021-04-08 13:11 ` [PATCH 4/8 v3] Input: cyttsp - Error message on boot mode exit error Linus Walleij
@ 2021-04-08 13:11 ` Linus Walleij
  2021-04-10  7:32   ` Dmitry Torokhov
  2021-04-08 13:11 ` [PATCH 6/8 v3] Input: cyttsp - Drop the phys path Linus Walleij
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Linus Walleij @ 2021-04-08 13:11 UTC (permalink / raw)
  To: Ferruh Yigit, Dmitry Torokhov, Javier Martinez Canillas
  Cc: Henrik Rydberg, linux-input, Linus Walleij

The data sheet for CY8CTMA340 specifies that the reset pulse
shall be at least 1 ms. Specify 1-2 ms with usleep_range()
to cut some slack for the scheduler.

Curiously the datasheet does not specify how long we have to
wait after a hard reset until the chip is up, but I have found
a vendor tree (Samsung GT-S7710) that has code for this touch
screen and there this is set to 5 ms so I use this with
the same 1 ms fuzz.

Reviewed-by: Javier Martinez Canillas <javier@dowhile0.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v3:
- Collect Javier's Reviewed-by
---
 drivers/input/touchscreen/cyttsp_core.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c
index 91f8f38b3f06..84f4f1c1a220 100644
--- a/drivers/input/touchscreen/cyttsp_core.c
+++ b/drivers/input/touchscreen/cyttsp_core.c
@@ -230,10 +230,16 @@ static int cyttsp_set_sysinfo_regs(struct cyttsp *ts)
 static void cyttsp_hard_reset(struct cyttsp *ts)
 {
 	if (ts->reset_gpio) {
+		/*
+		 * According to the CY8CTMA340 datasheet page 21, the external
+		 * reset pulse width should be >= 1 ms. The datasheet does not
+		 * specify how long we have to wait after reset but a vendor
+		 * tree specifies 5 ms here.
+		 */
 		gpiod_set_value_cansleep(ts->reset_gpio, 1);
-		msleep(CY_DELAY_DFLT);
+		usleep_range(1000, 2000);
 		gpiod_set_value_cansleep(ts->reset_gpio, 0);
-		msleep(CY_DELAY_DFLT);
+		usleep_range(5000, 6000);
 	}
 }
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 6/8 v3] Input: cyttsp - Drop the phys path
  2021-04-08 13:11 [PATCH 0/8 v3] Update CYTTSP driver Linus Walleij
                   ` (4 preceding siblings ...)
  2021-04-08 13:11 ` [PATCH 5/8 v3] Input: cyttsp - Reduce reset pulse timings Linus Walleij
@ 2021-04-08 13:11 ` Linus Walleij
  2021-04-10  7:33   ` Dmitry Torokhov
  2021-04-08 13:11 ` [PATCH 7/8 v3] Input: cyttsp - Set abs params for ABS_MT_TOUCH_MAJOR Linus Walleij
  2021-04-08 13:11 ` [PATCH 8/8 v3] Input: cyttsp - Flag the device properly Linus Walleij
  7 siblings, 1 reply; 15+ messages in thread
From: Linus Walleij @ 2021-04-08 13:11 UTC (permalink / raw)
  To: Ferruh Yigit, Dmitry Torokhov, Javier Martinez Canillas
  Cc: Henrik Rydberg, linux-input, Linus Walleij

When I test to use the CY8CTMA340 with PostmarketOS I don't
have any problem whatsoever in dropping this phys path,
it finds and uses the touchscreen just as well. I suppose
it is because userspace is using modern input libraries.

I challenge the maintainers to point out a valid and still
used userspace that actually need this. I say we drop it.

Reviewed-by: Javier Martinez Canillas <javier@dowhile0.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v3:
- Collect Javier's Reviewed-by
---
 drivers/input/touchscreen/cyttsp_core.c | 2 --
 drivers/input/touchscreen/cyttsp_core.h | 1 -
 2 files changed, 3 deletions(-)

diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c
index 84f4f1c1a220..8ae9f00e5e31 100644
--- a/drivers/input/touchscreen/cyttsp_core.c
+++ b/drivers/input/touchscreen/cyttsp_core.c
@@ -655,10 +655,8 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
 		return ERR_PTR(error);
 
 	init_completion(&ts->bl_ready);
-	snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(dev));
 
 	input_dev->name = "Cypress TTSP TouchScreen";
-	input_dev->phys = ts->phys;
 	input_dev->id.bustype = bus_ops->bustype;
 	input_dev->dev.parent = ts->dev;
 
diff --git a/drivers/input/touchscreen/cyttsp_core.h b/drivers/input/touchscreen/cyttsp_core.h
index c102a094e888..8eba9d8ba74a 100644
--- a/drivers/input/touchscreen/cyttsp_core.h
+++ b/drivers/input/touchscreen/cyttsp_core.h
@@ -115,7 +115,6 @@ struct cyttsp {
 	struct device *dev;
 	int irq;
 	struct input_dev *input;
-	char phys[32];
 	const struct cyttsp_bus_ops *bus_ops;
 	struct cyttsp_bootloader_data bl_data;
 	struct cyttsp_sysinfo_data sysinfo_data;
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 7/8 v3] Input: cyttsp - Set abs params for ABS_MT_TOUCH_MAJOR
  2021-04-08 13:11 [PATCH 0/8 v3] Update CYTTSP driver Linus Walleij
                   ` (5 preceding siblings ...)
  2021-04-08 13:11 ` [PATCH 6/8 v3] Input: cyttsp - Drop the phys path Linus Walleij
@ 2021-04-08 13:11 ` Linus Walleij
  2021-04-10  7:34   ` Dmitry Torokhov
  2021-04-08 13:11 ` [PATCH 8/8 v3] Input: cyttsp - Flag the device properly Linus Walleij
  7 siblings, 1 reply; 15+ messages in thread
From: Linus Walleij @ 2021-04-08 13:11 UTC (permalink / raw)
  To: Ferruh Yigit, Dmitry Torokhov, Javier Martinez Canillas
  Cc: Henrik Rydberg, linux-input, Linus Walleij

The driver is certainly reporting pressure in
cyttsp_report_tchdata() with
input_report_abs(input, ABS_MT_TOUCH_MAJOR, tch->z);
so we should also advertise this capability.

Reviewed-by: Javier Martinez Canillas <javier@dowhile0.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v3:
- Collect Javier's Reviewed-by.
---
 drivers/input/touchscreen/cyttsp_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c
index 8ae9f00e5e31..ac412bcb15d8 100644
--- a/drivers/input/touchscreen/cyttsp_core.c
+++ b/drivers/input/touchscreen/cyttsp_core.c
@@ -667,6 +667,9 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
 
 	input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_X);
 	input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_Y);
+	/* One byte for width 0..255 so this is the limit */
+	input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
+
 	touchscreen_parse_properties(input_dev, true, NULL);
 
 	error = input_mt_init_slots(input_dev, CY_MAX_ID, 0);
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 8/8 v3] Input: cyttsp - Flag the device properly
  2021-04-08 13:11 [PATCH 0/8 v3] Update CYTTSP driver Linus Walleij
                   ` (6 preceding siblings ...)
  2021-04-08 13:11 ` [PATCH 7/8 v3] Input: cyttsp - Set abs params for ABS_MT_TOUCH_MAJOR Linus Walleij
@ 2021-04-08 13:11 ` Linus Walleij
  2021-04-10  7:41   ` Dmitry Torokhov
  7 siblings, 1 reply; 15+ messages in thread
From: Linus Walleij @ 2021-04-08 13:11 UTC (permalink / raw)
  To: Ferruh Yigit, Dmitry Torokhov, Javier Martinez Canillas
  Cc: Henrik Rydberg, linux-input, Linus Walleij

This device is certainly a very simple touchscreen so
we set INPUT_MT_DIRECT.

The sibling driver for CY8CTMA140 also sets
INPUT_MT_DROP_UNUSED and experimenting with this driver
it clearly does not hurt: the touchscreen is working just
fine so let's set it for this one as well.

Reviewed-by: Javier Martinez Canillas <javier@dowhile0.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v3:
- Collect Javier's Reviewed-by.
---
 drivers/input/touchscreen/cyttsp_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c
index ac412bcb15d8..fb71cd0d2070 100644
--- a/drivers/input/touchscreen/cyttsp_core.c
+++ b/drivers/input/touchscreen/cyttsp_core.c
@@ -672,7 +672,8 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
 
 	touchscreen_parse_properties(input_dev, true, NULL);
 
-	error = input_mt_init_slots(input_dev, CY_MAX_ID, 0);
+	error = input_mt_init_slots(input_dev, CY_MAX_ID,
+				    INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED);
 	if (error) {
 		dev_err(dev, "Unable to init MT slots.\n");
 		return ERR_PTR(error);
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 4/8 v3] Input: cyttsp - Error message on boot mode exit error
  2021-04-08 13:11 ` [PATCH 4/8 v3] Input: cyttsp - Error message on boot mode exit error Linus Walleij
@ 2021-04-10  7:31   ` Dmitry Torokhov
  0 siblings, 0 replies; 15+ messages in thread
From: Dmitry Torokhov @ 2021-04-10  7:31 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Ferruh Yigit, Javier Martinez Canillas, Henrik Rydberg, linux-input

On Thu, Apr 08, 2021 at 03:11:49PM +0200, Linus Walleij wrote:
> Provide a proper error message when attempting to exit
> boot loader mode and failing, which is something that
> happened to me.
> 
> Reviewed-by: Javier Martinez Canillas <javier@dowhile0.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Applied, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 5/8 v3] Input: cyttsp - Reduce reset pulse timings
  2021-04-08 13:11 ` [PATCH 5/8 v3] Input: cyttsp - Reduce reset pulse timings Linus Walleij
@ 2021-04-10  7:32   ` Dmitry Torokhov
  0 siblings, 0 replies; 15+ messages in thread
From: Dmitry Torokhov @ 2021-04-10  7:32 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Javier Martinez Canillas, Henrik Rydberg, linux-input

On Thu, Apr 08, 2021 at 03:11:50PM +0200, Linus Walleij wrote:
> The data sheet for CY8CTMA340 specifies that the reset pulse
> shall be at least 1 ms. Specify 1-2 ms with usleep_range()
> to cut some slack for the scheduler.
> 
> Curiously the datasheet does not specify how long we have to
> wait after a hard reset until the chip is up, but I have found
> a vendor tree (Samsung GT-S7710) that has code for this touch
> screen and there this is set to 5 ms so I use this with
> the same 1 ms fuzz.
> 
> Reviewed-by: Javier Martinez Canillas <javier@dowhile0.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Applied, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 6/8 v3] Input: cyttsp - Drop the phys path
  2021-04-08 13:11 ` [PATCH 6/8 v3] Input: cyttsp - Drop the phys path Linus Walleij
@ 2021-04-10  7:33   ` Dmitry Torokhov
  0 siblings, 0 replies; 15+ messages in thread
From: Dmitry Torokhov @ 2021-04-10  7:33 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Javier Martinez Canillas, Henrik Rydberg, linux-input

On Thu, Apr 08, 2021 at 03:11:51PM +0200, Linus Walleij wrote:
> When I test to use the CY8CTMA340 with PostmarketOS I don't
> have any problem whatsoever in dropping this phys path,
> it finds and uses the touchscreen just as well. I suppose
> it is because userspace is using modern input libraries.
> 
> I challenge the maintainers to point out a valid and still
> used userspace that actually need this. I say we drop it.
> 
> Reviewed-by: Javier Martinez Canillas <javier@dowhile0.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Applied, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 7/8 v3] Input: cyttsp - Set abs params for ABS_MT_TOUCH_MAJOR
  2021-04-08 13:11 ` [PATCH 7/8 v3] Input: cyttsp - Set abs params for ABS_MT_TOUCH_MAJOR Linus Walleij
@ 2021-04-10  7:34   ` Dmitry Torokhov
  0 siblings, 0 replies; 15+ messages in thread
From: Dmitry Torokhov @ 2021-04-10  7:34 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Javier Martinez Canillas, Henrik Rydberg, linux-input

On Thu, Apr 08, 2021 at 03:11:52PM +0200, Linus Walleij wrote:
> The driver is certainly reporting pressure in
> cyttsp_report_tchdata() with
> input_report_abs(input, ABS_MT_TOUCH_MAJOR, tch->z);
> so we should also advertise this capability.
> 
> Reviewed-by: Javier Martinez Canillas <javier@dowhile0.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Applied, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 8/8 v3] Input: cyttsp - Flag the device properly
  2021-04-08 13:11 ` [PATCH 8/8 v3] Input: cyttsp - Flag the device properly Linus Walleij
@ 2021-04-10  7:41   ` Dmitry Torokhov
  0 siblings, 0 replies; 15+ messages in thread
From: Dmitry Torokhov @ 2021-04-10  7:41 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Javier Martinez Canillas, Henrik Rydberg, linux-input

Hi Linus,

On Thu, Apr 08, 2021 at 03:11:53PM +0200, Linus Walleij wrote:
> This device is certainly a very simple touchscreen so
> we set INPUT_MT_DIRECT.
> 
> The sibling driver for CY8CTMA140 also sets
> INPUT_MT_DROP_UNUSED and experimenting with this driver
> it clearly does not hurt: the touchscreen is working just
> fine so let's set it for this one as well.

This is not a good justification, and INPUT_MT_DROP_UNUSED is
essentially a noop if the driver does not use input_mt_sync_frame().

I dropped INPUT_MT_DROP_UNUSED from the patch and applied, but I would
appreciate a followup patch switching the driver to INPUT_MT_DROP_UNUSED
and adding input_mt_sync_frame() to cyttsp_report_tchdata() and removing
manual release of inactive slots from there (the "used" bitmap).

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/8 v3] Input: cyttsp - Convert bindings to YAML and extend
  2021-04-08 13:11 ` [PATCH 1/8 v3] Input: cyttsp - Convert bindings to YAML and extend Linus Walleij
@ 2021-04-10  7:44   ` Dmitry Torokhov
  0 siblings, 0 replies; 15+ messages in thread
From: Dmitry Torokhov @ 2021-04-10  7:44 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Ferruh Yigit, Javier Martinez Canillas, Henrik Rydberg,
	linux-input, devicetree, Rob Herring

Hi Linus,

On Thu, Apr 08, 2021 at 03:11:46PM +0200, Linus Walleij wrote:
> +
> +  interrupts:
> +    description: Interrupt to host, must be flagged as
> +      IRQ_TYPE_EDGE_FALLING.

I do not think this is such a great idea to mandate falling edge
interrupt. In fact, on devices that can support it I think level
interrupts would be better.

And I would prefer if we dropped IRQF_TRIGGER_FALLING from
devm_request_threaded_irq() in drivers/input/touchscreen/cyttsp_core.c
and rely on the platform to specify appropriate trigger.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-04-10  7:45 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08 13:11 [PATCH 0/8 v3] Update CYTTSP driver Linus Walleij
2021-04-08 13:11 ` [PATCH 1/8 v3] Input: cyttsp - Convert bindings to YAML and extend Linus Walleij
2021-04-10  7:44   ` Dmitry Torokhov
2021-04-08 13:11 ` [PATCH 2/8 v3] Input: cyttsp - Probe from compatibles Linus Walleij
2021-04-08 13:11 ` [PATCH 3/8 v3] Input: cyttsp - Obtain regulators Linus Walleij
2021-04-08 13:11 ` [PATCH 4/8 v3] Input: cyttsp - Error message on boot mode exit error Linus Walleij
2021-04-10  7:31   ` Dmitry Torokhov
2021-04-08 13:11 ` [PATCH 5/8 v3] Input: cyttsp - Reduce reset pulse timings Linus Walleij
2021-04-10  7:32   ` Dmitry Torokhov
2021-04-08 13:11 ` [PATCH 6/8 v3] Input: cyttsp - Drop the phys path Linus Walleij
2021-04-10  7:33   ` Dmitry Torokhov
2021-04-08 13:11 ` [PATCH 7/8 v3] Input: cyttsp - Set abs params for ABS_MT_TOUCH_MAJOR Linus Walleij
2021-04-10  7:34   ` Dmitry Torokhov
2021-04-08 13:11 ` [PATCH 8/8 v3] Input: cyttsp - Flag the device properly Linus Walleij
2021-04-10  7:41   ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).