linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 0/3] Support wakeup methods of Atmel maXTouch controllers
@ 2021-03-02 10:21 Dmitry Osipenko
  2021-03-02 10:21 ` [PATCH v6 1/3] dt-bindings: input: atmel_mxt_ts: Document atmel,wakeup-method and WAKE line GPIO Dmitry Osipenko
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Dmitry Osipenko @ 2021-03-02 10:21 UTC (permalink / raw)
  To: Nick Dyer, Dmitry Torokhov, Rob Herring, Thierry Reding,
	Jonathan Hunter, Linus Walleij, Jiada Wang
  Cc: linux-input, devicetree, linux-tegra, linux-kernel

Some Atmel maXTouch controllers, like mXT1386 and mXT3432S1 for example,
have a WAKE line that needs to be asserted in order to wake controller
from a deep sleep, otherwise it will be unusable. This series implements
support for the wakeup methods in accordance to the mXT1386 datasheet [1],
see page 29 (chapter "5.8 WAKE Line").

The mXT1386 is a widely used controller found on many older Android tablet
devices. Touchscreen on Acer A500 tablet now works properly after this
series.

This patchset is a continuation of the work originally started by
Jiada Wang [2].

[1] https://ww1.microchip.com/downloads/en/DeviceDoc/mXT1386_1vx_Datasheet_LX.pdf
[2] https://patchwork.kernel.org/project/linux-input/list/?series=357875

Changelog:

v6: - Added r-b from Rob Herring to the DT-binding patch that he gave
      to v4.

v5: - No code changes. Improved commit message of the "acer-a500: Add
      atmel,wakeup-method property" patch and added r-b from Linus Walleij
      to "Input: atmel_mxt_ts - support wakeup methods" patch that he gave
      to v4.

v4: - Improved commit message of the DT binding patch. No code changes.

v3: - Added "default: 0" to the atmel,wakeup-method property in the binding.

    - Added r-b from Linus Walleij to the binding patch.

    - The wake-GPIO is now toggled on touchscreen's start/stop in order to
      allow it to sleep during suspend. Suggested by Linus Walleij.

v2: - Fixed copy-paste bug in the code.

Dmitry Osipenko (3):
  dt-bindings: input: atmel_mxt_ts: Document atmel,wakeup-method and
    WAKE line GPIO
  Input: atmel_mxt_ts - support wakeup methods
  ARM: tegra: acer-a500: Add atmel,wakeup-method property

 .../bindings/input/atmel,maxtouch.yaml        | 29 +++++++
 .../boot/dts/tegra20-acer-a500-picasso.dts    |  3 +
 drivers/input/touchscreen/atmel_mxt_ts.c      | 78 +++++++++++++++++++
 include/dt-bindings/input/atmel-maxtouch.h    | 10 +++
 4 files changed, 120 insertions(+)
 create mode 100644 include/dt-bindings/input/atmel-maxtouch.h

-- 
2.29.2


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

* [PATCH v6 1/3] dt-bindings: input: atmel_mxt_ts: Document atmel,wakeup-method and WAKE line GPIO
  2021-03-02 10:21 [PATCH v6 0/3] Support wakeup methods of Atmel maXTouch controllers Dmitry Osipenko
@ 2021-03-02 10:21 ` Dmitry Osipenko
  2021-03-21 22:40   ` Dmitry Torokhov
  2021-03-02 10:21 ` [PATCH v6 2/3] Input: atmel_mxt_ts - support wakeup methods Dmitry Osipenko
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: Dmitry Osipenko @ 2021-03-02 10:21 UTC (permalink / raw)
  To: Nick Dyer, Dmitry Torokhov, Rob Herring, Thierry Reding,
	Jonathan Hunter, Linus Walleij, Jiada Wang
  Cc: linux-input, devicetree, linux-tegra, linux-kernel

Some Atmel touchscreen controllers have a WAKE line that needs to be
asserted low in order to wake up controller from a deep sleep. Document
the wakeup methods and the new GPIO properties.

Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 .../bindings/input/atmel,maxtouch.yaml        | 29 +++++++++++++++++++
 include/dt-bindings/input/atmel-maxtouch.h    | 10 +++++++
 2 files changed, 39 insertions(+)
 create mode 100644 include/dt-bindings/input/atmel-maxtouch.h

diff --git a/Documentation/devicetree/bindings/input/atmel,maxtouch.yaml b/Documentation/devicetree/bindings/input/atmel,maxtouch.yaml
index 8c6418f76e94..e6b03a1e7c30 100644
--- a/Documentation/devicetree/bindings/input/atmel,maxtouch.yaml
+++ b/Documentation/devicetree/bindings/input/atmel,maxtouch.yaml
@@ -39,6 +39,13 @@ properties:
       (active low). The line must be flagged with
       GPIO_ACTIVE_LOW.
 
+  wake-gpios:
+    maxItems: 1
+    description:
+      Optional GPIO specifier for the touchscreen's wake pin
+      (active low). The line must be flagged with
+      GPIO_ACTIVE_LOW.
+
   linux,gpio-keymap:
     $ref: /schemas/types.yaml#/definitions/uint32-array
     description: |
@@ -53,6 +60,26 @@ properties:
       or experiment to determine which bit corresponds to which input. Use
       KEY_RESERVED for unused padding values.
 
+  atmel,wakeup-method:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: |
+      The WAKE line is an active-low input that is used to wake up the touch
+      controller from deep-sleep mode before communication with the controller
+      could be started. This optional feature used to minimize current
+      consumption when the controller is in deep sleep mode. This feature is
+      relevant only to some controller families, like mXT1386 controller for
+      example.
+
+      The WAKE pin can be connected in one of the following ways:
+       1) left permanently low
+       2) connected to the I2C-compatible SCL pin
+       3) connected to a GPIO pin on the host
+    enum:
+      - 0 # ATMEL_MXT_WAKEUP_NONE
+      - 1 # ATMEL_MXT_WAKEUP_I2C_SCL
+      - 2 # ATMEL_MXT_WAKEUP_GPIO
+    default: 0
+
 required:
   - compatible
   - reg
@@ -63,6 +90,7 @@ additionalProperties: false
 examples:
   - |
     #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/input/atmel-maxtouch.h>
     #include <dt-bindings/gpio/gpio.h>
     i2c {
       #address-cells = <1>;
@@ -75,6 +103,7 @@ examples:
         reset-gpios = <&gpio 27 GPIO_ACTIVE_LOW>;
         vdda-supply = <&ab8500_ldo_aux2_reg>;
         vdd-supply = <&ab8500_ldo_aux5_reg>;
+        atmel,wakeup-method = <ATMEL_MXT_WAKEUP_I2C_SCL>;
       };
     };
 
diff --git a/include/dt-bindings/input/atmel-maxtouch.h b/include/dt-bindings/input/atmel-maxtouch.h
new file mode 100644
index 000000000000..7345ab32224d
--- /dev/null
+++ b/include/dt-bindings/input/atmel-maxtouch.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _DT_BINDINGS_ATMEL_MAXTOUCH_H
+#define _DT_BINDINGS_ATMEL_MAXTOUCH_H
+
+#define ATMEL_MXT_WAKEUP_NONE		0
+#define ATMEL_MXT_WAKEUP_I2C_SCL	1
+#define ATMEL_MXT_WAKEUP_GPIO		2
+
+#endif /* _DT_BINDINGS_ATMEL_MAXTOUCH_H */
-- 
2.29.2


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

* [PATCH v6 2/3] Input: atmel_mxt_ts - support wakeup methods
  2021-03-02 10:21 [PATCH v6 0/3] Support wakeup methods of Atmel maXTouch controllers Dmitry Osipenko
  2021-03-02 10:21 ` [PATCH v6 1/3] dt-bindings: input: atmel_mxt_ts: Document atmel,wakeup-method and WAKE line GPIO Dmitry Osipenko
@ 2021-03-02 10:21 ` Dmitry Osipenko
  2021-03-21 22:40   ` Dmitry Torokhov
  2021-03-02 10:21 ` [PATCH v6 3/3] ARM: tegra: acer-a500: Add atmel,wakeup-method property Dmitry Osipenko
  2021-03-20 16:02 ` [PATCH v6 0/3] Support wakeup methods of Atmel maXTouch controllers Dmitry Osipenko
  3 siblings, 1 reply; 13+ messages in thread
From: Dmitry Osipenko @ 2021-03-02 10:21 UTC (permalink / raw)
  To: Nick Dyer, Dmitry Torokhov, Rob Herring, Thierry Reding,
	Jonathan Hunter, Linus Walleij, Jiada Wang
  Cc: linux-input, devicetree, linux-tegra, linux-kernel

According to datasheets, chips like mXT1386 have a WAKE line, it is used
to wake the chip up from deep sleep mode before communicating with it via
the I2C-compatible interface.

If the WAKE line is connected to a GPIO line, the line must be asserted
25 ms before the host attempts to communicate with the controller. If the
WAKE line is connected to the SCL pin, the controller will send a NACK on
the first attempt to address it, the host must then retry 25 ms later.

Implement the wake-up methods in the driver. Touchscreen now works
properly on devices like Acer A500 tablet, fixing problems like this:

 atmel_mxt_ts 0-004c: __mxt_read_reg: i2c transfer failed (-121)
 atmel_mxt_ts 0-004c: mxt_bootloader_read: i2c recv failed (-121)
 atmel_mxt_ts 0-004c: Trying alternate bootloader address
 atmel_mxt_ts 0-004c: mxt_bootloader_read: i2c recv failed (-121)
 atmel_mxt_ts: probe of 0-004c failed with error -121

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 78 ++++++++++++++++++++++++
 1 file changed, 78 insertions(+)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 383a848eb601..5ed23689047b 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -31,6 +31,7 @@
 #include <media/v4l2-ioctl.h>
 #include <media/videobuf2-v4l2.h>
 #include <media/videobuf2-vmalloc.h>
+#include <dt-bindings/input/atmel-maxtouch.h>
 
 /* Firmware files */
 #define MXT_FW_NAME		"maxtouch.fw"
@@ -199,6 +200,7 @@ enum t100_type {
 #define MXT_CRC_TIMEOUT		1000	/* msec */
 #define MXT_FW_RESET_TIME	3000	/* msec */
 #define MXT_FW_CHG_TIMEOUT	300	/* msec */
+#define MXT_WAKEUP_TIME		25	/* msec */
 
 /* Command to unlock bootloader */
 #define MXT_UNLOCK_CMD_MSB	0xaa
@@ -312,6 +314,7 @@ struct mxt_data {
 	struct mxt_dbg dbg;
 	struct regulator_bulk_data regulators[2];
 	struct gpio_desc *reset_gpio;
+	struct gpio_desc *wake_gpio;
 	bool use_retrigen_workaround;
 
 	/* Cached parameters from object table */
@@ -342,6 +345,8 @@ struct mxt_data {
 	unsigned int t19_num_keys;
 
 	enum mxt_suspend_mode suspend_mode;
+
+	u32 wakeup_method;
 };
 
 struct mxt_vb2_buffer {
@@ -621,10 +626,42 @@ static int mxt_send_bootloader_cmd(struct mxt_data *data, bool unlock)
 	return mxt_bootloader_write(data, buf, sizeof(buf));
 }
 
+static bool mxt_wakeup_toggle(struct i2c_client *client,
+			      bool wake_up, bool in_i2c)
+{
+	struct mxt_data *data = i2c_get_clientdata(client);
+
+	switch (data->wakeup_method) {
+	case ATMEL_MXT_WAKEUP_I2C_SCL:
+		if (!in_i2c)
+			return false;
+		break;
+
+	case ATMEL_MXT_WAKEUP_GPIO:
+		if (in_i2c)
+			return false;
+
+		gpiod_set_value(data->wake_gpio, wake_up);
+		break;
+
+	default:
+		return false;
+	}
+
+	if (wake_up) {
+		dev_dbg(&client->dev, "waking up controller\n");
+
+		msleep(MXT_WAKEUP_TIME);
+	}
+
+	return true;
+}
+
 static int __mxt_read_reg(struct i2c_client *client,
 			       u16 reg, u16 len, void *val)
 {
 	struct i2c_msg xfer[2];
+	bool retried = false;
 	u8 buf[2];
 	int ret;
 
@@ -643,9 +680,13 @@ static int __mxt_read_reg(struct i2c_client *client,
 	xfer[1].len = len;
 	xfer[1].buf = val;
 
+retry:
 	ret = i2c_transfer(client->adapter, xfer, 2);
 	if (ret == 2) {
 		ret = 0;
+	} else if (!retried && mxt_wakeup_toggle(client, true, true)) {
+		retried = true;
+		goto retry;
 	} else {
 		if (ret >= 0)
 			ret = -EIO;
@@ -659,6 +700,7 @@ static int __mxt_read_reg(struct i2c_client *client,
 static int __mxt_write_reg(struct i2c_client *client, u16 reg, u16 len,
 			   const void *val)
 {
+	bool retried = false;
 	u8 *buf;
 	size_t count;
 	int ret;
@@ -672,9 +714,13 @@ static int __mxt_write_reg(struct i2c_client *client, u16 reg, u16 len,
 	buf[1] = (reg >> 8) & 0xff;
 	memcpy(&buf[2], val, len);
 
+retry:
 	ret = i2c_master_send(client, buf, count);
 	if (ret == count) {
 		ret = 0;
+	} else if (!retried && mxt_wakeup_toggle(client, true, true)) {
+		retried = true;
+		goto retry;
 	} else {
 		if (ret >= 0)
 			ret = -EIO;
@@ -2975,6 +3021,8 @@ static const struct attribute_group mxt_attr_group = {
 
 static void mxt_start(struct mxt_data *data)
 {
+	mxt_wakeup_toggle(data->client, true, false);
+
 	switch (data->suspend_mode) {
 	case MXT_SUSPEND_T9_CTRL:
 		mxt_soft_reset(data);
@@ -3009,6 +3057,8 @@ static void mxt_stop(struct mxt_data *data)
 		mxt_set_t7_power_cfg(data, MXT_POWER_CFG_DEEPSLEEP);
 		break;
 	}
+
+	mxt_wakeup_toggle(data->client, false, false);
 }
 
 static int mxt_input_open(struct input_dev *dev)
@@ -3155,6 +3205,15 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
 		return error;
 	}
 
+	/* Request the WAKE line as asserted so we go out of sleep */
+	data->wake_gpio = devm_gpiod_get_optional(&client->dev,
+						  "wake", GPIOD_OUT_HIGH);
+	if (IS_ERR(data->wake_gpio)) {
+		error = PTR_ERR(data->wake_gpio);
+		dev_err(&client->dev, "Failed to get wake gpio: %d\n", error);
+		return error;
+	}
+
 	error = devm_request_threaded_irq(&client->dev, client->irq,
 					  NULL, mxt_interrupt, IRQF_ONESHOT,
 					  client->name, data);
@@ -3185,6 +3244,25 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
 		msleep(MXT_RESET_INVALID_CHG);
 	}
 
+	/*
+	 * Controllers like mXT1386 have a dedicated WAKE line that could be
+	 * connected to a GPIO or to I2C SCL pin, or permanently asserted low.
+	 *
+	 * This WAKE line is used for waking controller from a deep-sleep and
+	 * it needs to be asserted low for 25 milliseconds before I2C transfers
+	 * could be accepted by controller if it was in a deep-sleep mode.
+	 * Controller will go into sleep automatically after 2 seconds of
+	 * inactivity if WAKE line is deasserted and deep sleep is activated.
+	 *
+	 * If WAKE line is connected to I2C SCL pin, then the first I2C transfer
+	 * will get an instant NAK and transfer needs to be retried after 25ms.
+	 *
+	 * If WAKE line is connected to a GPIO line, the line must be asserted
+	 * 25ms before the host attempts to communicate with the controller.
+	 */
+	device_property_read_u32(&client->dev, "atmel,wakeup-method",
+				 &data->wakeup_method);
+
 	error = mxt_initialize(data);
 	if (error)
 		goto err_disable_regulators;
-- 
2.29.2


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

* [PATCH v6 3/3] ARM: tegra: acer-a500: Add atmel,wakeup-method property
  2021-03-02 10:21 [PATCH v6 0/3] Support wakeup methods of Atmel maXTouch controllers Dmitry Osipenko
  2021-03-02 10:21 ` [PATCH v6 1/3] dt-bindings: input: atmel_mxt_ts: Document atmel,wakeup-method and WAKE line GPIO Dmitry Osipenko
  2021-03-02 10:21 ` [PATCH v6 2/3] Input: atmel_mxt_ts - support wakeup methods Dmitry Osipenko
@ 2021-03-02 10:21 ` Dmitry Osipenko
  2021-03-21 22:40   ` Dmitry Torokhov
  2021-03-20 16:02 ` [PATCH v6 0/3] Support wakeup methods of Atmel maXTouch controllers Dmitry Osipenko
  3 siblings, 1 reply; 13+ messages in thread
From: Dmitry Osipenko @ 2021-03-02 10:21 UTC (permalink / raw)
  To: Nick Dyer, Dmitry Torokhov, Rob Herring, Thierry Reding,
	Jonathan Hunter, Linus Walleij, Jiada Wang
  Cc: linux-input, devicetree, linux-tegra, linux-kernel

Acer A500 uses Atmel Maxtouch 1386 touchscreen controller. This controller
has WAKE line which could be connected to I2C clock lane, dedicated GPIO
or fixed to HIGH level. Controller wakes up from a deep sleep when WAKE
line is asserted low. Acer A500 has WAKE line connected to I2C clock and
Linux device driver doesn't work property without knowing what wakeup
method is used by h/w.

Add atmel,wakeup-method property to the touchscreen node.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 arch/arm/boot/dts/tegra20-acer-a500-picasso.dts | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/boot/dts/tegra20-acer-a500-picasso.dts b/arch/arm/boot/dts/tegra20-acer-a500-picasso.dts
index d3b99535d755..40c1bab22155 100644
--- a/arch/arm/boot/dts/tegra20-acer-a500-picasso.dts
+++ b/arch/arm/boot/dts/tegra20-acer-a500-picasso.dts
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 /dts-v1/;
 
+#include <dt-bindings/input/atmel-maxtouch.h>
 #include <dt-bindings/input/gpio-keys.h>
 #include <dt-bindings/input/input.h>
 #include <dt-bindings/thermal/thermal.h>
@@ -450,6 +451,8 @@ touchscreen@4c {
 
 			avdd-supply = <&vdd_3v3_sys>;
 			vdd-supply  = <&vdd_3v3_sys>;
+
+			atmel,wakeup-method = <ATMEL_MXT_WAKEUP_I2C_SCL>;
 		};
 
 		gyroscope@68 {
-- 
2.29.2


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

* Re: [PATCH v6 0/3] Support wakeup methods of Atmel maXTouch controllers
  2021-03-02 10:21 [PATCH v6 0/3] Support wakeup methods of Atmel maXTouch controllers Dmitry Osipenko
                   ` (2 preceding siblings ...)
  2021-03-02 10:21 ` [PATCH v6 3/3] ARM: tegra: acer-a500: Add atmel,wakeup-method property Dmitry Osipenko
@ 2021-03-20 16:02 ` Dmitry Osipenko
  2021-03-21 22:44   ` Dmitry Torokhov
  3 siblings, 1 reply; 13+ messages in thread
From: Dmitry Osipenko @ 2021-03-20 16:02 UTC (permalink / raw)
  To: Nick Dyer, Dmitry Torokhov, Rob Herring, Thierry Reding,
	Jonathan Hunter, Linus Walleij, Jiada Wang
  Cc: linux-input, devicetree, linux-tegra, linux-kernel

02.03.2021 13:21, Dmitry Osipenko пишет:
> Some Atmel maXTouch controllers, like mXT1386 and mXT3432S1 for example,
> have a WAKE line that needs to be asserted in order to wake controller
> from a deep sleep, otherwise it will be unusable. This series implements
> support for the wakeup methods in accordance to the mXT1386 datasheet [1],
> see page 29 (chapter "5.8 WAKE Line").
> 
> The mXT1386 is a widely used controller found on many older Android tablet
> devices. Touchscreen on Acer A500 tablet now works properly after this
> series.
> 
> This patchset is a continuation of the work originally started by
> Jiada Wang [2].
> 
> [1] https://ww1.microchip.com/downloads/en/DeviceDoc/mXT1386_1vx_Datasheet_LX.pdf
> [2] https://patchwork.kernel.org/project/linux-input/list/?series=357875

Hi,

This series is very wanted by Android tablet devices from Acer, Asus and
other vendors which use Maxtouch 1386 controller. Touchscreens don't
work without the wakeup support, i.e. without this series. The wakeup
support is implemented in accordance to the datasheet and touchscreens
are working excellent using these patches.

Could you please take this series into v5.13?

Or could you please let me know what exactly needs to be improved?

Thanks in advance.

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

* Re: [PATCH v6 1/3] dt-bindings: input: atmel_mxt_ts: Document atmel,wakeup-method and WAKE line GPIO
  2021-03-02 10:21 ` [PATCH v6 1/3] dt-bindings: input: atmel_mxt_ts: Document atmel,wakeup-method and WAKE line GPIO Dmitry Osipenko
@ 2021-03-21 22:40   ` Dmitry Torokhov
  0 siblings, 0 replies; 13+ messages in thread
From: Dmitry Torokhov @ 2021-03-21 22:40 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Nick Dyer, Rob Herring, Thierry Reding, Jonathan Hunter,
	Linus Walleij, Jiada Wang, linux-input, devicetree, linux-tegra,
	linux-kernel

On Tue, Mar 02, 2021 at 01:21:56PM +0300, Dmitry Osipenko wrote:
> Some Atmel touchscreen controllers have a WAKE line that needs to be
> asserted low in order to wake up controller from a deep sleep. Document
> the wakeup methods and the new GPIO properties.
> 
> Reviewed-by: Rob Herring <robh@kernel.org>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>

Applied, thank you.

-- 
Dmitry

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

* Re: [PATCH v6 2/3] Input: atmel_mxt_ts - support wakeup methods
  2021-03-02 10:21 ` [PATCH v6 2/3] Input: atmel_mxt_ts - support wakeup methods Dmitry Osipenko
@ 2021-03-21 22:40   ` Dmitry Torokhov
  0 siblings, 0 replies; 13+ messages in thread
From: Dmitry Torokhov @ 2021-03-21 22:40 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Nick Dyer, Rob Herring, Thierry Reding, Jonathan Hunter,
	Linus Walleij, Jiada Wang, linux-input, devicetree, linux-tegra,
	linux-kernel

On Tue, Mar 02, 2021 at 01:21:57PM +0300, Dmitry Osipenko wrote:
> According to datasheets, chips like mXT1386 have a WAKE line, it is used
> to wake the chip up from deep sleep mode before communicating with it via
> the I2C-compatible interface.
> 
> If the WAKE line is connected to a GPIO line, the line must be asserted
> 25 ms before the host attempts to communicate with the controller. If the
> WAKE line is connected to the SCL pin, the controller will send a NACK on
> the first attempt to address it, the host must then retry 25 ms later.
> 
> Implement the wake-up methods in the driver. Touchscreen now works
> properly on devices like Acer A500 tablet, fixing problems like this:
> 
>  atmel_mxt_ts 0-004c: __mxt_read_reg: i2c transfer failed (-121)
>  atmel_mxt_ts 0-004c: mxt_bootloader_read: i2c recv failed (-121)
>  atmel_mxt_ts 0-004c: Trying alternate bootloader address
>  atmel_mxt_ts 0-004c: mxt_bootloader_read: i2c recv failed (-121)
>  atmel_mxt_ts: probe of 0-004c failed with error -121
> 
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>

Applied, thank you.

-- 
Dmitry

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

* Re: [PATCH v6 3/3] ARM: tegra: acer-a500: Add atmel,wakeup-method property
  2021-03-02 10:21 ` [PATCH v6 3/3] ARM: tegra: acer-a500: Add atmel,wakeup-method property Dmitry Osipenko
@ 2021-03-21 22:40   ` Dmitry Torokhov
  2021-03-25 14:10     ` Thierry Reding
  0 siblings, 1 reply; 13+ messages in thread
From: Dmitry Torokhov @ 2021-03-21 22:40 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Nick Dyer, Rob Herring, Thierry Reding, Jonathan Hunter,
	Linus Walleij, Jiada Wang, linux-input, devicetree, linux-tegra,
	linux-kernel

On Tue, Mar 02, 2021 at 01:21:58PM +0300, Dmitry Osipenko wrote:
> Acer A500 uses Atmel Maxtouch 1386 touchscreen controller. This controller
> has WAKE line which could be connected to I2C clock lane, dedicated GPIO
> or fixed to HIGH level. Controller wakes up from a deep sleep when WAKE
> line is asserted low. Acer A500 has WAKE line connected to I2C clock and
> Linux device driver doesn't work property without knowing what wakeup
> method is used by h/w.
> 
> Add atmel,wakeup-method property to the touchscreen node.
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>

Applied, thank you.

-- 
Dmitry

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

* Re: [PATCH v6 0/3] Support wakeup methods of Atmel maXTouch controllers
  2021-03-20 16:02 ` [PATCH v6 0/3] Support wakeup methods of Atmel maXTouch controllers Dmitry Osipenko
@ 2021-03-21 22:44   ` Dmitry Torokhov
  2021-03-21 23:08     ` Dmitry Osipenko
  0 siblings, 1 reply; 13+ messages in thread
From: Dmitry Torokhov @ 2021-03-21 22:44 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Nick Dyer, Rob Herring, Thierry Reding, Jonathan Hunter,
	Linus Walleij, Jiada Wang, linux-input, devicetree, linux-tegra,
	linux-kernel

Hi Dmitry,

On Sat, Mar 20, 2021 at 07:02:43PM +0300, Dmitry Osipenko wrote:
> 02.03.2021 13:21, Dmitry Osipenko пишет:
> > Some Atmel maXTouch controllers, like mXT1386 and mXT3432S1 for example,
> > have a WAKE line that needs to be asserted in order to wake controller
> > from a deep sleep, otherwise it will be unusable. This series implements
> > support for the wakeup methods in accordance to the mXT1386 datasheet [1],
> > see page 29 (chapter "5.8 WAKE Line").
> > 
> > The mXT1386 is a widely used controller found on many older Android tablet
> > devices. Touchscreen on Acer A500 tablet now works properly after this
> > series.
> > 
> > This patchset is a continuation of the work originally started by
> > Jiada Wang [2].
> > 
> > [1] https://ww1.microchip.com/downloads/en/DeviceDoc/mXT1386_1vx_Datasheet_LX.pdf
> > [2] https://patchwork.kernel.org/project/linux-input/list/?series=357875
> 
> Hi,
> 
> This series is very wanted by Android tablet devices from Acer, Asus and
> other vendors which use Maxtouch 1386 controller. Touchscreens don't
> work without the wakeup support, i.e. without this series. The wakeup
> support is implemented in accordance to the datasheet and touchscreens
> are working excellent using these patches.
> 
> Could you please take this series into v5.13?
> 
> Or could you please let me know what exactly needs to be improved?

Sorry, I was still slightly unhappy that we still are not tracking the
state of controller and opportunistically retrying failed I2C transfers,
but as I am failing to find time to come up with another solution I have
just applied your series.

Thanks.

-- 
Dmitry

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

* Re: [PATCH v6 0/3] Support wakeup methods of Atmel maXTouch controllers
  2021-03-21 22:44   ` Dmitry Torokhov
@ 2021-03-21 23:08     ` Dmitry Osipenko
  0 siblings, 0 replies; 13+ messages in thread
From: Dmitry Osipenko @ 2021-03-21 23:08 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Nick Dyer, Rob Herring, Thierry Reding, Jonathan Hunter,
	Linus Walleij, Jiada Wang, linux-input, devicetree, linux-tegra,
	linux-kernel

22.03.2021 01:44, Dmitry Torokhov пишет:
> Hi Dmitry,
> 
> On Sat, Mar 20, 2021 at 07:02:43PM +0300, Dmitry Osipenko wrote:
>> 02.03.2021 13:21, Dmitry Osipenko пишет:
>>> Some Atmel maXTouch controllers, like mXT1386 and mXT3432S1 for example,
>>> have a WAKE line that needs to be asserted in order to wake controller
>>> from a deep sleep, otherwise it will be unusable. This series implements
>>> support for the wakeup methods in accordance to the mXT1386 datasheet [1],
>>> see page 29 (chapter "5.8 WAKE Line").
>>>
>>> The mXT1386 is a widely used controller found on many older Android tablet
>>> devices. Touchscreen on Acer A500 tablet now works properly after this
>>> series.
>>>
>>> This patchset is a continuation of the work originally started by
>>> Jiada Wang [2].
>>>
>>> [1] https://ww1.microchip.com/downloads/en/DeviceDoc/mXT1386_1vx_Datasheet_LX.pdf
>>> [2] https://patchwork.kernel.org/project/linux-input/list/?series=357875
>>
>> Hi,
>>
>> This series is very wanted by Android tablet devices from Acer, Asus and
>> other vendors which use Maxtouch 1386 controller. Touchscreens don't
>> work without the wakeup support, i.e. without this series. The wakeup
>> support is implemented in accordance to the datasheet and touchscreens
>> are working excellent using these patches.
>>
>> Could you please take this series into v5.13?
>>
>> Or could you please let me know what exactly needs to be improved?
> 
> Sorry, I was still slightly unhappy that we still are not tracking the
> state of controller and opportunistically retrying failed I2C transfers,
> but as I am failing to find time to come up with another solution I have
> just applied your series.

Thank you! I don't have other solutions either, although /I think/
potentially it should be possible to differentiate the I2C error here.
On NVIDIA Tegra I see that I2C controller always gets a h/w NAK on TS
wake-up and it returns -EREMOTEIO in this case. IIRC, some other
non-NVIDIA I2C drivers always return -EIO on any error, so this method
isn't universal, but certainly it feels like there is some a room for
further improvements.

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

* Re: [PATCH v6 3/3] ARM: tegra: acer-a500: Add atmel,wakeup-method property
  2021-03-21 22:40   ` Dmitry Torokhov
@ 2021-03-25 14:10     ` Thierry Reding
  2021-03-25 18:15       ` Dmitry Torokhov
  0 siblings, 1 reply; 13+ messages in thread
From: Thierry Reding @ 2021-03-25 14:10 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Dmitry Osipenko, Nick Dyer, Rob Herring, Jonathan Hunter,
	Linus Walleij, Jiada Wang, linux-input, devicetree, linux-tegra,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1216 bytes --]

On Sun, Mar 21, 2021 at 03:40:28PM -0700, Dmitry Torokhov wrote:
> On Tue, Mar 02, 2021 at 01:21:58PM +0300, Dmitry Osipenko wrote:
> > Acer A500 uses Atmel Maxtouch 1386 touchscreen controller. This controller
> > has WAKE line which could be connected to I2C clock lane, dedicated GPIO
> > or fixed to HIGH level. Controller wakes up from a deep sleep when WAKE
> > line is asserted low. Acer A500 has WAKE line connected to I2C clock and
> > Linux device driver doesn't work property without knowing what wakeup
> > method is used by h/w.
> > 
> > Add atmel,wakeup-method property to the touchscreen node.
> > 
> > Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> 
> Applied, thank you.

I noticed that you had applied this as I was applying a different patch
that touches the same area and it causes a conflict. In general I prefer
to pick up all device tree changes into the Tegra tree, specifically to
avoid such conflicts.

That said, I didn't see an email from Stephen about this causing a
conflict in linux-next, so perhaps it's fine. If this pops up again it
might be worth considering to drop this from your tree so that I can
resolve the conflict in the Tegra tree.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v6 3/3] ARM: tegra: acer-a500: Add atmel,wakeup-method property
  2021-03-25 14:10     ` Thierry Reding
@ 2021-03-25 18:15       ` Dmitry Torokhov
  2021-03-26 12:21         ` Thierry Reding
  0 siblings, 1 reply; 13+ messages in thread
From: Dmitry Torokhov @ 2021-03-25 18:15 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Dmitry Osipenko, Nick Dyer, Rob Herring, Jonathan Hunter,
	Linus Walleij, Jiada Wang, linux-input, devicetree, linux-tegra,
	linux-kernel

On Thu, Mar 25, 2021 at 03:10:25PM +0100, Thierry Reding wrote:
> On Sun, Mar 21, 2021 at 03:40:28PM -0700, Dmitry Torokhov wrote:
> > On Tue, Mar 02, 2021 at 01:21:58PM +0300, Dmitry Osipenko wrote:
> > > Acer A500 uses Atmel Maxtouch 1386 touchscreen controller. This controller
> > > has WAKE line which could be connected to I2C clock lane, dedicated GPIO
> > > or fixed to HIGH level. Controller wakes up from a deep sleep when WAKE
> > > line is asserted low. Acer A500 has WAKE line connected to I2C clock and
> > > Linux device driver doesn't work property without knowing what wakeup
> > > method is used by h/w.
> > > 
> > > Add atmel,wakeup-method property to the touchscreen node.
> > > 
> > > Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> > 
> > Applied, thank you.
> 
> I noticed that you had applied this as I was applying a different patch
> that touches the same area and it causes a conflict. In general I prefer
> to pick up all device tree changes into the Tegra tree, specifically to
> avoid such conflicts.
> 
> That said, I didn't see an email from Stephen about this causing a
> conflict in linux-next, so perhaps it's fine. If this pops up again it
> might be worth considering to drop this from your tree so that I can
> resolve the conflict in the Tegra tree.

Sorry about that, I went ahead and dropped the patch from my branch.

Thanks.

-- 
Dmitry

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

* Re: [PATCH v6 3/3] ARM: tegra: acer-a500: Add atmel,wakeup-method property
  2021-03-25 18:15       ` Dmitry Torokhov
@ 2021-03-26 12:21         ` Thierry Reding
  0 siblings, 0 replies; 13+ messages in thread
From: Thierry Reding @ 2021-03-26 12:21 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Dmitry Osipenko, Nick Dyer, Rob Herring, Jonathan Hunter,
	Linus Walleij, Jiada Wang, linux-input, devicetree, linux-tegra,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1564 bytes --]

On Thu, Mar 25, 2021 at 11:15:54AM -0700, Dmitry Torokhov wrote:
> On Thu, Mar 25, 2021 at 03:10:25PM +0100, Thierry Reding wrote:
> > On Sun, Mar 21, 2021 at 03:40:28PM -0700, Dmitry Torokhov wrote:
> > > On Tue, Mar 02, 2021 at 01:21:58PM +0300, Dmitry Osipenko wrote:
> > > > Acer A500 uses Atmel Maxtouch 1386 touchscreen controller. This controller
> > > > has WAKE line which could be connected to I2C clock lane, dedicated GPIO
> > > > or fixed to HIGH level. Controller wakes up from a deep sleep when WAKE
> > > > line is asserted low. Acer A500 has WAKE line connected to I2C clock and
> > > > Linux device driver doesn't work property without knowing what wakeup
> > > > method is used by h/w.
> > > > 
> > > > Add atmel,wakeup-method property to the touchscreen node.
> > > > 
> > > > Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> > > 
> > > Applied, thank you.
> > 
> > I noticed that you had applied this as I was applying a different patch
> > that touches the same area and it causes a conflict. In general I prefer
> > to pick up all device tree changes into the Tegra tree, specifically to
> > avoid such conflicts.
> > 
> > That said, I didn't see an email from Stephen about this causing a
> > conflict in linux-next, so perhaps it's fine. If this pops up again it
> > might be worth considering to drop this from your tree so that I can
> > resolve the conflict in the Tegra tree.
> 
> Sorry about that, I went ahead and dropped the patch from my branch.

Applied to the Tegra tree now.

Thanks,
Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2021-03-26 12:22 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-02 10:21 [PATCH v6 0/3] Support wakeup methods of Atmel maXTouch controllers Dmitry Osipenko
2021-03-02 10:21 ` [PATCH v6 1/3] dt-bindings: input: atmel_mxt_ts: Document atmel,wakeup-method and WAKE line GPIO Dmitry Osipenko
2021-03-21 22:40   ` Dmitry Torokhov
2021-03-02 10:21 ` [PATCH v6 2/3] Input: atmel_mxt_ts - support wakeup methods Dmitry Osipenko
2021-03-21 22:40   ` Dmitry Torokhov
2021-03-02 10:21 ` [PATCH v6 3/3] ARM: tegra: acer-a500: Add atmel,wakeup-method property Dmitry Osipenko
2021-03-21 22:40   ` Dmitry Torokhov
2021-03-25 14:10     ` Thierry Reding
2021-03-25 18:15       ` Dmitry Torokhov
2021-03-26 12:21         ` Thierry Reding
2021-03-20 16:02 ` [PATCH v6 0/3] Support wakeup methods of Atmel maXTouch controllers Dmitry Osipenko
2021-03-21 22:44   ` Dmitry Torokhov
2021-03-21 23:08     ` Dmitry Osipenko

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).