Skip to contentSkip to conversation

Support wakeup methods of Atmel maXTouch controllers

PATCH Superseded Dmitry Osipenko 3 participants 11 messages Dec 6, 2020 – Jan 7, 2021

Subsystems (6)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover Support wakeup methods of Atmel maXTouch controllers

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:

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-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
Signature · 1 line
2.29.2
#1 lore raw

PATCH v3 1/3 dt-bindings: input: atmel_mxt_ts: Document atmel,wakeup-method and wake-GPIO

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 wake-GPIO properties.

---
 .../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
Documentation/devicetree/bindings/input/atmel,maxtouch.yaml +29 -0
index 8c6418f76e94..e6b03a1e7c30 100644
@@ -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>;
       };
     };
 
include/dt-bindings/input/atmel-maxtouch.h new file +10 -0
new file mode 100644
index 000000000000..7345ab32224d
@@ -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 */
Signature · 1 line
2.29.2
#5 lore raw

PATCH v3 3/3 ARM: tegra: acer-a500: Add atmel,wakeup-method property

In reply to Dmitry Osipenko

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

---
 arch/arm/boot/dts/tegra20-acer-a500-picasso.dts | 3 +++
 1 file changed, 3 insertions(+)
arch/arm/boot/dts/tegra20-acer-a500-picasso.dts +3 -0
index d3b99535d755..40c1bab22155 100644
@@ -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 {
Signature · 1 line
2.29.2
#4 lore raw

PATCH v3 2/3 Input: atmel_mxt_ts - support wakeup methods

In reply to Dmitry Osipenko

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

---
 drivers/input/touchscreen/atmel_mxt_ts.c | 78 ++++++++++++++++++++++++
 1 file changed, 78 insertions(+)
drivers/input/touchscreen/atmel_mxt_ts.c +78 -0
index 2b3fff0822fe..e3342fdfe9f3 100644
@@ -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 {
@@ -626,10 +631,42 @@ static int mxt_send_bootloader_cmd(struct mxt_data *data, bool unlock)
 	return 0;
 }
 
+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;
 
@@ -648,9 +685,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;
@@ -664,6 +705,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;
@@ -677,9 +719,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;
@@ -2980,6 +3026,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);
@@ -3014,6 +3062,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)
@@ -3160,6 +3210,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);
@@ -3190,6 +3249,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;
Signature · 1 line
2.29.2
maintainer
#2 lore raw

Re: [PATCH v3 1/3] dt-bindings: input: atmel_mxt_ts: Document atmel,wakeup-method and wake-GPIO

In reply to Dmitry Osipenko
Quoted 3 lines · Dmitry Osipenko

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 wake-GPIO properties.

wake-GPIO?

Quoted 89 lines
---
 .../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
Documentation/devicetree/bindings/input/atmel,maxtouch.yaml +29 -0
index 8c6418f76e94..e6b03a1e7c30 100644
@@ -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>;
       };
     };
 
include/dt-bindings/input/atmel-maxtouch.h new file +10 -0
new file mode 100644
index 000000000000..7345ab32224d
@@ -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 */
Signature · 1 line
2.29.2
#3 lore raw

Re: [PATCH v3 1/3] dt-bindings: input: atmel_mxt_ts: Document atmel,wakeup-method and wake-GPIO

10.12.2020 06:44, Rob Herring пишет:

Quoted 6 lines · Dmitry Osipenko
Quoted 3 lines

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 wake-GPIO properties.

wake-GPIO?

The "wake-gpios" is the new property and it has "maxItems: 1", hence the wake-GPIO.

Quoted 89 lines
Quoted 89 lines
---
 .../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
Documentation/devicetree/bindings/input/atmel,maxtouch.yaml +29 -0
index 8c6418f76e94..e6b03a1e7c30 100644
@@ -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>;
       };
     };
 
include/dt-bindings/input/atmel-maxtouch.h new file +10 -0
new file mode 100644
index 000000000000..7345ab32224d
@@ -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 */
Signature · 1 line
2.29.2
maintainer
#6 lore raw
In reply to Dmitry Osipenko

Hi Dmitry,

Quoted 9 lines · 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.

I am trying to understand how your controller is configured on that system. Could you please enable all debug messages in the driver and post the logs? I am a bit confused why the controller needs to be woken up twice in mxt_start() given that according to the spec it is supposed to stay up for 2 seconds after successful I2C transfer...

Thanks!

Signature · 1 line
Dmitry
#7 lore raw

Hello,

12.12.2020 05:43, Dmitry Torokhov пишет:

Quoted 13 lines

Hi Dmitry,

Quoted 9 lines · 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.

Quoted 5 lines

I am trying to understand how your controller is configured on that system. Could you please enable all debug messages in the driver and post the logs? I am a bit confused why the controller needs to be woken up twice in mxt_start() given that according to the spec it is supposed to stay up for 2 seconds after successful I2C transfer...

From the page 30 in the datasheet:

"Note that when the mXT1386 is sent into deep sleep mode, it goes to sleep immediately. In this case the two-second timeout does not apply until the WAKE pin is asserted."

The debug log seems confirm that quote:

...

[ 1.196404] Family: 160 Variant: 0 Firmware V1.0.AA Objects: 18
[ 1.196572] T37 Start:118 Size:130 Instances:1 Report IDs:0-0
[ 1.196586] T44 Start:248 Size:1 Instances:1 Report IDs:0-0
[ 1.196597] T5 Start:249 Size:9 Instances:1 Report IDs:0-0
[ 1.196608] T6 Start:258 Size:6 Instances:1 Report IDs:1-1
[ 1.196617] T38 Start:264 Size:64 Instances:1 Report IDs:0-0
[ 1.196628] T7 Start:328 Size:3 Instances:1 Report IDs:0-0
[ 1.196638] T8 Start:331 Size:10 Instances:1 Report IDs:0-0
[ 1.196648] T9 Start:341 Size:34 Instances:1 Report IDs:2-17
[ 1.196658] T15 Start:375 Size:11 Instances:2 Report IDs:18-19
[ 1.196668] T18 Start:397 Size:2 Instances:1 Report IDs:0-0
[ 1.196678] T22 Start:399 Size:17 Instances:1 Report IDs:20-20
[ 1.196688] T24 Start:416 Size:19 Instances:1 Report IDs:21-24
[ 1.196698] T25 Start:435 Size:14 Instances:1 Report IDs:25-25
[ 1.196708] T27 Start:449 Size:7 Instances:1 Report IDs:26-26
[ 1.196718] T28 Start:456 Size:6 Instances:1 Report IDs:27-27
[ 1.196728] T40 Start:462 Size:5 Instances:1 Report IDs:0-0
[ 1.196738] T41 Start:467 Size:6 Instances:1 Report IDs:0-0
[ 1.196748] T43 Start:473 Size:6 Instances:1 Report IDs:0-0
[ 1.196852] Direct firmware load for maxtouch.cfg failed with error -2
[ 1.197305] T6 Config Checksum: 0x8D7459
[ 1.197318] T6 Status 0x90 RESET CAL
[ 1.197543] Initialized power cfg: ACTV 10, IDLE 50
[ 1.198387] Touchscreen size X1279Y799
...
[ 1.211686] T6 Status 0x00 OK
...
[15.576573] Set T7 ACTV:10 IDLE:50
[15.592142] T6 Status 0x10 CAL
[15.597920] T6 Status 0x00 OK
[15.604846] Set T7 ACTV:0 IDLE:0
[15.831477] waking up controller
[15.862912] Set T7 ACTV:10 IDLE:50
[15.872783] Set T7 ACTV:0 IDLE:0
[15.880333] T6 Status 0x10 CAL
[15.946853] Set T7 ACTV:10 IDLE:50
[15.956582] Set T7 ACTV:0 IDLE:0
...
[27.897337] waking up controller
[27.924172] Set T7 ACTV:10 IDLE:50
[27.947286] T6 Status 0x00 OK
[27.959754] Set T7 ACTV:0 IDLE:0
[27.970258] Set T7 ACTV:10 IDLE:50
[27.987546] T6 Status 0x10 CAL
[27.993327] T6 Status 0x00 OK
maintainer
#8 lore raw
Quoted 57 lines · Dmitry Osipenko

Hello,

12.12.2020 05:43, Dmitry Torokhov пишет:

Quoted 13 lines

Hi Dmitry,

Quoted 9 lines · 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.

Quoted 5 lines

I am trying to understand how your controller is configured on that system. Could you please enable all debug messages in the driver and post the logs? I am a bit confused why the controller needs to be woken up twice in mxt_start() given that according to the spec it is supposed to stay up for 2 seconds after successful I2C transfer...

From the page 30 in the datasheet:

"Note that when the mXT1386 is sent into deep sleep mode, it goes to sleep immediately. In this case the two-second timeout does not apply until the WAKE pin is asserted."

The debug log seems confirm that quote:

...

[ 1.196404] Family: 160 Variant: 0 Firmware V1.0.AA Objects: 18
[ 1.196572] T37 Start:118 Size:130 Instances:1 Report IDs:0-0
[ 1.196586] T44 Start:248 Size:1 Instances:1 Report IDs:0-0
[ 1.196597] T5 Start:249 Size:9 Instances:1 Report IDs:0-0
[ 1.196608] T6 Start:258 Size:6 Instances:1 Report IDs:1-1
[ 1.196617] T38 Start:264 Size:64 Instances:1 Report IDs:0-0
[ 1.196628] T7 Start:328 Size:3 Instances:1 Report IDs:0-0
[ 1.196638] T8 Start:331 Size:10 Instances:1 Report IDs:0-0
[ 1.196648] T9 Start:341 Size:34 Instances:1 Report IDs:2-17
[ 1.196658] T15 Start:375 Size:11 Instances:2 Report IDs:18-19
[ 1.196668] T18 Start:397 Size:2 Instances:1 Report IDs:0-0
[ 1.196678] T22 Start:399 Size:17 Instances:1 Report IDs:20-20
[ 1.196688] T24 Start:416 Size:19 Instances:1 Report IDs:21-24
[ 1.196698] T25 Start:435 Size:14 Instances:1 Report IDs:25-25
[ 1.196708] T27 Start:449 Size:7 Instances:1 Report IDs:26-26
[ 1.196718] T28 Start:456 Size:6 Instances:1 Report IDs:27-27
[ 1.196728] T40 Start:462 Size:5 Instances:1 Report IDs:0-0
[ 1.196738] T41 Start:467 Size:6 Instances:1 Report IDs:0-0
[ 1.196748] T43 Start:473 Size:6 Instances:1 Report IDs:0-0
[ 1.196852] Direct firmware load for maxtouch.cfg failed with error -2
[ 1.197305] T6 Config Checksum: 0x8D7459
[ 1.197318] T6 Status 0x90 RESET CAL
[ 1.197543] Initialized power cfg: ACTV 10, IDLE 50
[ 1.198387] Touchscreen size X1279Y799
...
[ 1.211686] T6 Status 0x00 OK
Quoted 8 lines

...

[15.576573] Set T7 ACTV:10 IDLE:50
[15.592142] T6 Status 0x10 CAL
[15.597920] T6 Status 0x00 OK
[15.604846] Set T7 ACTV:0 IDLE:0
[15.831477] waking up controller
[15.862912] Set T7 ACTV:10 IDLE:50
[15.872783] Set T7 ACTV:0 IDLE:0

Thank you for the logs. I am confused where these calls to put the controller into deep sleep are coming from. Does something constantly open and close input device? Do you have any additional patches? We definitely do not issue deep sleep request in mxt_start(). Do you mind putting dump_stack() into mxt_set_t7_power_cfg() to see where the calls are coming from?

I also do not see additional "waking up controller" messages after requesting the chip via T7 to be configured to be active, which I'd expected to see if we indeed needed to wake it up again for T6 to succeed.

Thanks.

Signature · 1 line
Dmitry
#9 lore raw

13.12.2020 07:41, Dmitry Torokhov пишет:

Quoted 3 lines

Thank you for the logs. I am confused where these calls to put the controller into deep sleep are coming from. Does something constantly open and close input device?

Input devices are re-opened multiple times during Linux distro boot-up, a regular Ubuntu 20.10 in this case.

Quoted 1 line

Do you have any additional patches?

No, I'm using next-20201211 + this "wakeup methods" patchset.

Quoted 3 lines

We definitely do not issue deep sleep request in mxt_start(). Do you mind putting dump_stack() into mxt_set_t7_power_cfg() to see where the calls are coming from?

Please see the log below, I added it like this:

(quoted diff) +0 -0

b/drivers/input/touchscreen/atmel_mxt_ts.c
index e3342fdfe9f3..bbc5a5ee158a 100644

drivers/input/touchscreen/atmel_mxt_ts.c +0 -0
@@ -2271,6 +2271,8 @@ static int mxt_set_t7_power_cfg(struct mxt_data

*data, u8 sleep)
dev_dbg(dev, "Set T7 ACTV:%d IDLE:%d\n",
new_config->active, new_config->idle);

+ dump_stack();
+
return 0;
}

Quoted 4 lines

I also do not see additional "waking up controller" messages after requesting the chip via T7 to be configured to be active, which I'd expected to see if we indeed needed to wake it up again for T6 to succeed.

I'm not familiar with what controller does internally, hence no clue.

[ 1.195295] Family: 160 Variant: 0 Firmware V1.0.AA Objects: 18
[ 1.195468] T37 Start:118 Size:130 Instances:1 Report IDs:0-0
[ 1.195482] T44 Start:248 Size:1 Instances:1 Report IDs:0-0
[ 1.195493] T5 Start:249 Size:9 Instances:1 Report IDs:0-0
[ 1.195503] T6 Start:258 Size:6 Instances:1 Report IDs:1-1
[ 1.195513] T38 Start:264 Size:64 Instances:1 Report IDs:0-0
[ 1.195523] T7 Start:328 Size:3 Instances:1 Report IDs:0-0
[ 1.195533] T8 Start:331 Size:10 Instances:1 Report IDs:0-0
[ 1.195543] T9 Start:341 Size:34 Instances:1 Report IDs:2-17
[ 1.195553] T15 Start:375 Size:11 Instances:2 Report IDs:18-19
[ 1.195563] T18 Start:397 Size:2 Instances:1 Report IDs:0-0
[ 1.195573] T22 Start:399 Size:17 Instances:1 Report IDs:20-20
[ 1.195583] T24 Start:416 Size:19 Instances:1 Report IDs:21-24
[ 1.195593] T25 Start:435 Size:14 Instances:1 Report IDs:25-25
[ 1.195602] T27 Start:449 Size:7 Instances:1 Report IDs:26-26
[ 1.195612] T28 Start:456 Size:6 Instances:1 Report IDs:27-27
[ 1.195622] T40 Start:462 Size:5 Instances:1 Report IDs:0-0
[ 1.195631] T41 Start:467 Size:6 Instances:1 Report IDs:0-0
[ 1.195641] T43 Start:473 Size:6 Instances:1 Report IDs:0-0
[ 1.195746] Direct firmware load for maxtouch.cfg failed with error -2
[ 1.196199] T6 Config Checksum: 0x8D7459
[ 1.196212] T6 Status 0x90 RESET CAL
[ 1.196428] Initialized power cfg: ACTV 10, IDLE 50
[ 1.197275] Touchscreen size X1279Y799
[ 1.210563] T6 Status 0x00 OK
[14.866461] Set T7 ACTV:10 IDLE:50
[14.866495] CPU: 1 PID: 209 Comm: systemd-udevd Tainted: G        W
[14.866507] Hardware name: NVIDIA Tegra SoC (Flattened Device Tree)
[14.866523]  (unwind_backtrace) from  (show_stack)
[14.866568]  (show_stack) from  (dump_stack)
[14.866599]  (dump_stack) from  (mxt_set_t7_power_cfg)
[14.866635]  (mxt_set_t7_power_cfg) from  (mxt_start)
[14.866654]  (mxt_start) from  (mxt_input_open)
[14.866673]  (mxt_input_open) from  (input_open_device)
[14.866708]  (input_open_device) from  (evdev_open+0x113/0x134)
[14.866735]  (evdev_open) from  (chrdev_openc)
[14.866763]  (chrdev_open) from  (do_dentry_open4)
[14.866791]  (do_dentry_open) from  (path_openat+0x6b9/0xa04)
[14.866815]  (path_openat) from  (do_filp_open)
[14.866833]  (do_filp_open) from  (do_sys_openat2+0x1bf/0x23c)
[14.866850]  (do_sys_openat2) from  (do_sys_open)
[14.866872]  (do_sys_open) from  (__sys_trace_return+0x1/0x16)
[14.894683] Set T7 ACTV:0 IDLE:0
[14.894719] CPU: 1 PID: 209 Comm: systemd-udevd Tainted: G        W
[14.894732] Hardware name: NVIDIA Tegra SoC (Flattened Device Tree)
[14.894748]  (unwind_backtrace) from  (show_stack)
[14.894791]  (show_stack) from  (dump_stack)
[14.894822]  (dump_stack) from  (mxt_set_t7_power_cfg)
[14.894856]  (mxt_set_t7_power_cfg) from  (mxt_stop)
[14.894875]  (mxt_stop) from  (input_close_device)
[14.894908]  (input_close_device) from  (evdev_release)
[14.894934]  (evdev_release) from  (__fput8)
[14.894958]  (__fput) from  (task_work_run)
[14.894975]  (task_work_run) from  (do_work_pending+0x38d/0x438)
[14.894991]  (do_work_pending) from  (slow_work_pending+0x9/0x16)
[14.898242] T6 Status 0x10 CAL
[15.186570] Set T7 ACTV:10 IDLE:50
[15.186594] CPU: 0 PID: 212 Comm: libinput-fuzz-e Tainted: G        W
[15.186605] Hardware name: NVIDIA Tegra SoC (Flattened Device Tree)
[15.186615]  (unwind_backtrace) from  (show_stack)
[15.186648]  (show_stack) from  (dump_stack)
[15.186671]  (dump_stack) from  (mxt_set_t7_power_cfg)
[15.186699]  (mxt_set_t7_power_cfg) from  (mxt_start)
[15.186715]  (mxt_start) from  (mxt_input_open)
[15.186732]  (mxt_input_open) from  (input_open_device)
[15.186764]  (input_open_device) from  (evdev_open+0x113/0x134)
[15.186786]  (evdev_open) from  (chrdev_openc)
[15.186808]  (chrdev_open) from  (do_dentry_open4)
[15.186830]  (do_dentry_open) from  (path_openat+0x6b9/0xa04)
[15.186848]  (path_openat) from  (do_filp_open)
[15.186863]  (do_filp_open) from  (do_sys_openat2+0x1bf/0x23c)
[15.186878]  (do_sys_openat2) from  (do_sys_open)
[15.186895]  (do_sys_open) from  (__sys_trace_return+0x1/0x16)
[15.210404] T6 Status 0x00 OK
[15.229106] Set T7 ACTV:0 IDLE:0
[15.229132] CPU: 0 PID: 212 Comm: libinput-fuzz-e Tainted: G        W
[15.229148] Hardware name: NVIDIA Tegra SoC (Flattened Device Tree)
[15.229164]  (unwind_backtrace) from  (show_stack)
[15.229208]  (show_stack) from  (dump_stack)
[15.229237]  (dump_stack) from  (mxt_set_t7_power_cfg)
[15.229273]  (mxt_set_t7_power_cfg) from  (mxt_stop)
[15.229294]  (mxt_stop) from  (input_close_device)
[15.229323]  (input_close_device) from  (evdev_release)
[15.229350]  (evdev_release) from  (__fput8)
[15.229370]  (__fput) from  (task_work_run)
[15.229386]  (task_work_run) from  (do_work_pending+0x38d/0x438)
[15.229402]  (do_work_pending) from  (slow_work_pending+0x9/0x16)
[15.322473] waking up controller
[15.357423] Set T7 ACTV:10 IDLE:50
[15.357450] CPU: 1 PID: 216 Comm: libinput-fuzz-t Tainted: G        W
[15.357463] Hardware name: NVIDIA Tegra SoC (Flattened Device Tree)
[15.357476]  (unwind_backtrace) from  (show_stack)
[15.357510]  (show_stack) from  (dump_stack)
[15.357537]  (dump_stack) from  (mxt_set_t7_power_cfg)
[15.357566]  (mxt_set_t7_power_cfg) from  (mxt_start)
[15.357586]  (mxt_start) from  (mxt_input_open)
[15.357604]  (mxt_input_open) from  (input_open_device)
[15.357632]  (input_open_device) from  (evdev_open+0x113/0x134)
[15.357655]  (evdev_open) from  (chrdev_openc)
[15.357679]  (chrdev_open) from  (do_dentry_open4)
[15.357702]  (do_dentry_open) from  (path_openat+0x6b9/0xa04)
[15.357721]  (path_openat) from  (do_filp_open)
[15.357737]  (do_filp_open) from  (do_sys_openat2+0x1bf/0x23c)
[15.357754]  (do_sys_openat2) from  (do_sys_open)
[15.357773]  (do_sys_open) from  (__sys_trace_return+0x1/0x16)
[15.373658] Set T7 ACTV:0 IDLE:0
[15.373683] CPU: 1 PID: 216 Comm: libinput-fuzz-t Tainted: G        W
[15.373696] Hardware name: NVIDIA Tegra SoC (Flattened Device Tree)
[15.373708]  (unwind_backtrace) from  (show_stack)
[15.373744]  (show_stack) from  (dump_stack)
[15.373770]  (dump_stack) from  (mxt_set_t7_power_cfg)
[15.373817]  (mxt_set_t7_power_cfg) from  (mxt_stop)
[15.373856]  (mxt_stop) from  (input_close_device)
[15.373904]  (input_close_device) from  (evdev_release)
[15.373947]  (evdev_release) from  (__fput8)
[15.373971]  (__fput) from  (task_work_run)
[15.373987]  (task_work_run) from  (do_work_pending+0x38d/0x438)
[15.374003]  (do_work_pending) from  (slow_work_pending+0x9/0x16)
[15.375130] T6 Status 0x10 CAL
[26.500032] waking up controller
[26.526733] Set T7 ACTV:10 IDLE:50
[26.526772] CPU: 1 PID: 497 Comm: Xorg Tainted: G        W
[26.526788] Hardware name: NVIDIA Tegra SoC (Flattened Device Tree)
[26.526809]  (unwind_backtrace) from  (show_stack)
[26.526862]  (show_stack) from  (dump_stack)
[26.526903]  (dump_stack) from  (mxt_set_t7_power_cfg)
[26.526943]  (mxt_set_t7_power_cfg) from  (mxt_start)
[26.526965]  (mxt_start) from  (mxt_input_open)
[26.526986]  (mxt_input_open) from  (input_open_device)
[26.527023]  (input_open_device) from  (evdev_open+0x113/0x134)
[26.527051]  (evdev_open) from  (chrdev_openc)
[26.527080]  (chrdev_open) from  (do_dentry_open4)
[26.527108]  (do_dentry_open) from  (path_openat+0x6b9/0xa04)
[26.527130]  (path_openat) from  (do_filp_open)
[26.527149]  (do_filp_open) from  (do_sys_openat2+0x1bf/0x23c)
[26.527167]  (do_sys_openat2) from  (do_sys_open)
[26.527189]  (do_sys_open) from  (ret_fast_syscall+0x1/0x26)
[26.550377] T6 Status 0x00 OK
[26.564628] Set T7 ACTV:0 IDLE:0
[26.564659] CPU: 0 PID: 497 Comm: Xorg Tainted: G        W
[26.564672] Hardware name: NVIDIA Tegra SoC (Flattened Device Tree)
[26.564688]  (unwind_backtrace) from  (show_stack)
[26.564729]  (show_stack) from  (dump_stack)
[26.564759]  (dump_stack) from  (mxt_set_t7_power_cfg)
[26.564793]  (mxt_set_t7_power_cfg) from  (mxt_stop)
[26.564811]  (mxt_stop) from  (input_close_device)
[26.564844]  (input_close_device) from  (evdev_release)
[26.564871]  (evdev_release) from  (__fput8)
[26.564892]  (__fput) from  (task_work_run)
[26.564909]  (task_work_run) from  (do_work_pending+0x38d/0x438)
[26.564924]  (do_work_pending) from  (slow_work_pending+0x9/0x16)
[26.575062] Set T7 ACTV:10 IDLE:50
[26.575097] CPU: 1 PID: 497 Comm: Xorg Tainted: G        W
[26.575114] Hardware name: NVIDIA Tegra SoC (Flattened Device Tree)
[26.575132]  (unwind_backtrace) from  (show_stack)
[26.575189]  (show_stack) from  (dump_stack)
[26.575228]  (dump_stack) from  (mxt_set_t7_power_cfg)
[26.575269]  (mxt_set_t7_power_cfg) from  (mxt_start)
[26.575294]  (mxt_start) from  (mxt_input_open)
[26.575319]  (mxt_input_open) from  (input_open_device)
[26.575363]  (input_open_device) from  (evdev_open+0x113/0x134)
[26.575398]  (evdev_open) from  (chrdev_openc)
[26.575433]  (chrdev_open) from  (do_dentry_open4)
[26.575469]  (do_dentry_open) from  (path_openat+0x6b9/0xa04)
[26.575495]  (path_openat) from  (do_filp_open)
[26.575518]  (do_filp_open) from  (do_sys_openat2+0x1bf/0x23c)
[26.575540]  (do_sys_openat2) from  (do_sys_open)
[26.575566]  (do_sys_open) from  (ret_fast_syscall+0x1/0x26)
[26.577569] waking up controller
[26.656736] T6 Status 0x10 CAL
[26.662621] T6 Status 0x00 OK
#10 lore raw

13.12.2020 12:26, Dmitry Osipenko пишет:

Quoted 38 lines

13.12.2020 07:41, Dmitry Torokhov пишет:

Quoted 3 lines

Thank you for the logs. I am confused where these calls to put the controller into deep sleep are coming from. Does something constantly open and close input device?

Input devices are re-opened multiple times during Linux distro boot-up, a regular Ubuntu 20.10 in this case.

Quoted 1 line

Do you have any additional patches?

No, I'm using next-20201211 + this "wakeup methods" patchset.

Quoted 3 lines

We definitely do not issue deep sleep request in mxt_start(). Do you mind putting dump_stack() into mxt_set_t7_power_cfg() to see where the calls are coming from?

Please see the log below, I added it like this:

drivers/input/touchscreen/atmel_mxt_ts.c +2 -0
index e3342fdfe9f3..bbc5a5ee158a 100644
@@ -2271,6 +2271,8 @@ static int mxt_set_t7_power_cfg(struct mxt_data
 *data, u8 sleep)
 	dev_dbg(dev, "Set T7 ACTV:%d IDLE:%d\n",
 		new_config->active, new_config->idle);
 
+	dump_stack();
+
 	return 0;
 }
Quoted 5 lines

I also do not see additional "waking up controller" messages after requesting the chip via T7 to be configured to be active, which I'd expected to see if we indeed needed to wake it up again for T6 to succeed.

Quoted 5 lines

I'm not familiar with what controller does internally, hence no clue.

[ 1.195295] Family: 160 Variant: 0 Firmware V1.0.AA Objects: 18
[ 1.195468] T37 Start:118 Size:130 Instances:1 Report IDs:0-0

...
Dmitry Torokhov, do you have any more comments? Are you okay with v3? If yes, could you please pick up patches into -next?