linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/7] HID/arm64: dts: qcom: sc8280xp-x13s: fix touchscreen power on
@ 2024-05-07 14:48 Johan Hovold
  2024-05-07 14:48 ` [PATCH v2 1/7] dt-bindings: HID: i2c-hid: add dedicated Ilitek ILI2901 schema Johan Hovold
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Johan Hovold @ 2024-05-07 14:48 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Bjorn Andersson
  Cc: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Konrad Dybcio, Linus Walleij, Douglas Anderson, linux-input,
	devicetree, linux-arm-msm, linux-kernel, Johan Hovold

The Elan eKTH5015M touch controller on the X13s requires a 300 ms delay
before sending commands after having deasserted reset during power on.

This series switches the X13s devicetree to use the Elan specific
binding so that the OS can determine the required power-on sequence and
make sure that the controller is always detected during boot. [1]

The Elan hid-i2c driver currently asserts reset unconditionally during
suspend, which does not work on the X13s where the touch controller
supply is shared with other peripherals that may remain powered. Holding
the controller in reset can increase power consumption and also leaks
current through the reset circuitry pull ups.

Note that the latter also affects X13s variants where the touchscreen is
not populated as the driver also exits probe() with reset asserted.

Fix this by adding a new 'no-reset-on-power-off' devicetree property
which can be used by the OS to determine when reset needs to be asserted
on power down and when it safe and desirable to leave it deasserted.

I tried to look for drivers that had already addressed this but it was
only after I finished implementing this that I noticed Doug's reference
to commit 18eeef46d359 ("HID: i2c-hid: goodix: Tie the reset line to
true state of the regulator"), which tried to solve a related problem.

That commit has since been reverted but ultimately resulted in commit
7607f12ba735 ("HID: i2c-hid: goodix: Add support for
"goodix,no-reset-during-suspend" property") being merged to handle the
related case where the touch controller supply is always on.

The implementation is very similar, but I decided to use the slightly
more generic 'no-reset-on-power-off' property name after considering a
number of alternatives (including trying to describe the hardware
configuration in the name). (And as this is not vendor specific, I left
out the prefix.)

Note that my X13s does not have a touchscreen, but I have done partial
verification of the implementation using that machine and the sc8280xp
CRD reference design. Bjorn has promised to help out with final
verification on an X13s with a touchscreen.

The devicetree changes are expected to go in through the Qualcomm tree
once the binding and driver updates have been merged.

Johan


[1] The reset signal is currently deasserted using the pin configuration
    and the controller would be detected if probe is deferred or if user
    space triggers a reprobe through sysfs.

Changes in v2
 - drop redundant 'items' from binding
 - include a "should" in description of 'no-reset-on-power-off' property
 - always assert reset on probe
 - enable elan i2c-hid driver in arm64 defconfig

Johan Hovold (7):
  dt-bindings: HID: i2c-hid: add dedicated Ilitek ILI2901 schema
  dt-bindings: HID: i2c-hid: elan: add Elan eKTH5015M
  dt-bindings: HID: i2c-hid: elan: add 'no-reset-on-power-off' property
  HID: i2c-hid: elan: fix reset suspend current leakage
  arm64: dts: qcom: sc8280xp-x13s: fix touchscreen power on
  arm64: dts: qcom: sc8280xp-crd: use external pull up for touch reset
  arm64: defconfig: enable Elan i2c-hid driver

 .../bindings/input/elan,ekth6915.yaml         | 19 ++++--
 .../bindings/input/ilitek,ili2901.yaml        | 66 +++++++++++++++++++
 arch/arm64/boot/dts/qcom/sc8280xp-crd.dts     |  3 +-
 .../qcom/sc8280xp-lenovo-thinkpad-x13s.dts    | 15 +++--
 arch/arm64/configs/defconfig                  |  1 +
 drivers/hid/i2c-hid/i2c-hid-of-elan.c         | 59 +++++++++++++----
 6 files changed, 137 insertions(+), 26 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/input/ilitek,ili2901.yaml

-- 
2.43.2


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

* [PATCH v2 1/7] dt-bindings: HID: i2c-hid: add dedicated Ilitek ILI2901 schema
  2024-05-07 14:48 [PATCH v2 0/7] HID/arm64: dts: qcom: sc8280xp-x13s: fix touchscreen power on Johan Hovold
@ 2024-05-07 14:48 ` Johan Hovold
  2024-05-07 14:48 ` [PATCH v2 2/7] dt-bindings: HID: i2c-hid: elan: add Elan eKTH5015M Johan Hovold
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Johan Hovold @ 2024-05-07 14:48 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Bjorn Andersson
  Cc: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Konrad Dybcio, Linus Walleij, Douglas Anderson, linux-input,
	devicetree, linux-arm-msm, linux-kernel, Johan Hovold,
	Zhengqiao Xia, Krzysztof Kozlowski

The Ilitek ILI2901 touch screen controller was apparently incorrectly
added to the Elan eKTH6915 schema simply because it also has a reset
gpio and is currently managed by the Elan driver in Linux.

The two controllers are not related even if an unfortunate wording in
the commit message adding the Ilitek compatible made it sound like they
were.

Add a dedicated schema for the ILI2901 which does not specify the I2C
address (which is likely 0x41 rather than 0x10 as for other Ilitek touch
controllers) to avoid cluttering the Elan schema with unrelated devices
and to make it easier to find the correct schema when adding further
Ilitek controllers.

Fixes: d74ac6f60a7e ("dt-bindings: HID: i2c-hid: elan: Introduce Ilitek ili2901")
Cc: Zhengqiao Xia <xiazhengqiao@huaqin.corp-partner.google.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 .../bindings/input/elan,ekth6915.yaml         |  1 -
 .../bindings/input/ilitek,ili2901.yaml        | 66 +++++++++++++++++++
 2 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/input/ilitek,ili2901.yaml

diff --git a/Documentation/devicetree/bindings/input/elan,ekth6915.yaml b/Documentation/devicetree/bindings/input/elan,ekth6915.yaml
index dc4ac41f2441..c1fcf8c90c24 100644
--- a/Documentation/devicetree/bindings/input/elan,ekth6915.yaml
+++ b/Documentation/devicetree/bindings/input/elan,ekth6915.yaml
@@ -20,7 +20,6 @@ properties:
   compatible:
     enum:
       - elan,ekth6915
-      - ilitek,ili2901
 
   reg:
     const: 0x10
diff --git a/Documentation/devicetree/bindings/input/ilitek,ili2901.yaml b/Documentation/devicetree/bindings/input/ilitek,ili2901.yaml
new file mode 100644
index 000000000000..1abeec768d79
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/ilitek,ili2901.yaml
@@ -0,0 +1,66 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/ilitek,ili2901.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Ilitek ILI2901 touchscreen controller
+
+maintainers:
+  - Jiri Kosina <jkosina@suse.com>
+
+description:
+  Supports the Ilitek ILI2901 touchscreen controller.
+  This touchscreen controller uses the i2c-hid protocol with a reset GPIO.
+
+allOf:
+  - $ref: /schemas/input/touchscreen/touchscreen.yaml#
+
+properties:
+  compatible:
+    enum:
+      - ilitek,ili2901
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  panel: true
+
+  reset-gpios:
+    maxItems: 1
+
+  vcc33-supply: true
+
+  vccio-supply: true
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - vcc33-supply
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      touchscreen@41 {
+        compatible = "ilitek,ili2901";
+        reg = <0x41>;
+
+        interrupt-parent = <&tlmm>;
+        interrupts = <9 IRQ_TYPE_LEVEL_LOW>;
+
+        reset-gpios = <&tlmm 8 GPIO_ACTIVE_LOW>;
+        vcc33-supply = <&pp3300_ts>;
+      };
+    };
-- 
2.43.2


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

* [PATCH v2 2/7] dt-bindings: HID: i2c-hid: elan: add Elan eKTH5015M
  2024-05-07 14:48 [PATCH v2 0/7] HID/arm64: dts: qcom: sc8280xp-x13s: fix touchscreen power on Johan Hovold
  2024-05-07 14:48 ` [PATCH v2 1/7] dt-bindings: HID: i2c-hid: add dedicated Ilitek ILI2901 schema Johan Hovold
@ 2024-05-07 14:48 ` Johan Hovold
  2024-05-07 14:48 ` [PATCH v2 3/7] dt-bindings: HID: i2c-hid: elan: add 'no-reset-on-power-off' property Johan Hovold
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Johan Hovold @ 2024-05-07 14:48 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Bjorn Andersson
  Cc: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Konrad Dybcio, Linus Walleij, Douglas Anderson, linux-input,
	devicetree, linux-arm-msm, linux-kernel, Johan Hovold,
	Krzysztof Kozlowski

Add a compatible string for the Elan eKTH5015M touch controller.

Judging from the current binding and commit bd3cba00dcc6 ("HID: i2c-hid:
elan: Add support for Elan eKTH6915 i2c-hid touchscreens"), eKTH5015M
appears to be compatible with eKTH6915. Notably the power-on sequence is
the same.

While at it, drop a redundant label from the example.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 .../devicetree/bindings/input/elan,ekth6915.yaml     | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/elan,ekth6915.yaml b/Documentation/devicetree/bindings/input/elan,ekth6915.yaml
index c1fcf8c90c24..be84f7ed0abc 100644
--- a/Documentation/devicetree/bindings/input/elan,ekth6915.yaml
+++ b/Documentation/devicetree/bindings/input/elan,ekth6915.yaml
@@ -18,8 +18,12 @@ allOf:
 
 properties:
   compatible:
-    enum:
-      - elan,ekth6915
+    oneOf:
+      - items:
+          - enum:
+              - elan,ekth5015m
+          - const: elan,ekth6915
+      - const: elan,ekth6915
 
   reg:
     const: 0x10
@@ -57,8 +61,8 @@ examples:
       #address-cells = <1>;
       #size-cells = <0>;
 
-      ap_ts: touchscreen@10 {
-        compatible = "elan,ekth6915";
+      touchscreen@10 {
+        compatible = "elan,ekth5015m", "elan,ekth6915";
         reg = <0x10>;
 
         interrupt-parent = <&tlmm>;
-- 
2.43.2


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

* [PATCH v2 3/7] dt-bindings: HID: i2c-hid: elan: add 'no-reset-on-power-off' property
  2024-05-07 14:48 [PATCH v2 0/7] HID/arm64: dts: qcom: sc8280xp-x13s: fix touchscreen power on Johan Hovold
  2024-05-07 14:48 ` [PATCH v2 1/7] dt-bindings: HID: i2c-hid: add dedicated Ilitek ILI2901 schema Johan Hovold
  2024-05-07 14:48 ` [PATCH v2 2/7] dt-bindings: HID: i2c-hid: elan: add Elan eKTH5015M Johan Hovold
@ 2024-05-07 14:48 ` Johan Hovold
  2024-05-08  7:29   ` Krzysztof Kozlowski
  2024-05-27 13:01   ` Linus Walleij
  2024-05-07 14:48 ` [PATCH v2 4/7] HID: i2c-hid: elan: fix reset suspend current leakage Johan Hovold
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 14+ messages in thread
From: Johan Hovold @ 2024-05-07 14:48 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Bjorn Andersson
  Cc: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Konrad Dybcio, Linus Walleij, Douglas Anderson, linux-input,
	devicetree, linux-arm-msm, linux-kernel, Johan Hovold

When the power supply is shared with other peripherals the reset line
can be wired in such a way that it can remain deasserted regardless of
whether the supply is on or not.

This is important as it can be used to avoid holding the controller in
reset for extended periods of time when it remains powered, something
which can lead to increased power consumption. Leaving reset deasserted
also avoids leaking current through the reset circuitry pull-up
resistors.

Add a new 'no-reset-on-power-off' devicetree property which can be used
by the OS to determine when reset needs to be asserted on power down.

Note that this property can also be used when the supply cannot be
turned off by the OS at all.

Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 Documentation/devicetree/bindings/input/elan,ekth6915.yaml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/elan,ekth6915.yaml b/Documentation/devicetree/bindings/input/elan,ekth6915.yaml
index be84f7ed0abc..a62916d07a08 100644
--- a/Documentation/devicetree/bindings/input/elan,ekth6915.yaml
+++ b/Documentation/devicetree/bindings/input/elan,ekth6915.yaml
@@ -36,6 +36,12 @@ properties:
   reset-gpios:
     description: Reset GPIO; not all touchscreens using eKTH6915 hook this up.
 
+  no-reset-on-power-off:
+    type: boolean
+    description:
+      Reset line is wired so that it can (and should) be left deasserted when
+      the power supply is off.
+
   vcc33-supply:
     description: The 3.3V supply to the touchscreen.
 
-- 
2.43.2


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

* [PATCH v2 4/7] HID: i2c-hid: elan: fix reset suspend current leakage
  2024-05-07 14:48 [PATCH v2 0/7] HID/arm64: dts: qcom: sc8280xp-x13s: fix touchscreen power on Johan Hovold
                   ` (2 preceding siblings ...)
  2024-05-07 14:48 ` [PATCH v2 3/7] dt-bindings: HID: i2c-hid: elan: add 'no-reset-on-power-off' property Johan Hovold
@ 2024-05-07 14:48 ` Johan Hovold
  2024-05-10 23:36   ` Doug Anderson
  2024-05-07 14:48 ` [PATCH v2 5/7] arm64: dts: qcom: sc8280xp-x13s: fix touchscreen power on Johan Hovold
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Johan Hovold @ 2024-05-07 14:48 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Bjorn Andersson
  Cc: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Konrad Dybcio, Linus Walleij, Douglas Anderson, linux-input,
	devicetree, linux-arm-msm, linux-kernel, Johan Hovold, stable,
	Steev Klimaszewski

The Elan eKTH5015M touch controller found on the Lenovo ThinkPad X13s
shares the VCC33 supply with other peripherals that may remain powered
during suspend (e.g. when enabled as wakeup sources).

The reset line is also wired so that it can be left deasserted when the
supply is off.

This is important as it avoids holding the controller in reset for
extended periods of time when it remains powered, which can lead to
increased power consumption, and also avoids leaking current through the
X13s reset circuitry during suspend (and after driver unbind).

Use the new 'no-reset-on-power-off' devicetree property to determine
when reset needs to be asserted on power down.

Notably this also avoids wasting power on machine variants without a
touchscreen for which the driver would otherwise exit probe with reset
asserted.

Fixes: bd3cba00dcc6 ("HID: i2c-hid: elan: Add support for Elan eKTH6915 i2c-hid touchscreens")
Cc: stable@vger.kernel.org	# 6.0
Cc: Douglas Anderson <dianders@chromium.org>
Tested-by: Steev Klimaszewski <steev@kali.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 drivers/hid/i2c-hid/i2c-hid-of-elan.c | 59 +++++++++++++++++++++------
 1 file changed, 47 insertions(+), 12 deletions(-)

diff --git a/drivers/hid/i2c-hid/i2c-hid-of-elan.c b/drivers/hid/i2c-hid/i2c-hid-of-elan.c
index 5b91fb106cfc..091e37933225 100644
--- a/drivers/hid/i2c-hid/i2c-hid-of-elan.c
+++ b/drivers/hid/i2c-hid/i2c-hid-of-elan.c
@@ -31,6 +31,7 @@ struct i2c_hid_of_elan {
 	struct regulator *vcc33;
 	struct regulator *vccio;
 	struct gpio_desc *reset_gpio;
+	bool no_reset_on_power_off;
 	const struct elan_i2c_hid_chip_data *chip_data;
 };
 
@@ -40,17 +41,17 @@ static int elan_i2c_hid_power_up(struct i2chid_ops *ops)
 		container_of(ops, struct i2c_hid_of_elan, ops);
 	int ret;
 
+	gpiod_set_value_cansleep(ihid_elan->reset_gpio, 1);
+
 	if (ihid_elan->vcc33) {
 		ret = regulator_enable(ihid_elan->vcc33);
 		if (ret)
-			return ret;
+			goto err_deassert_reset;
 	}
 
 	ret = regulator_enable(ihid_elan->vccio);
-	if (ret) {
-		regulator_disable(ihid_elan->vcc33);
-		return ret;
-	}
+	if (ret)
+		goto err_disable_vcc33;
 
 	if (ihid_elan->chip_data->post_power_delay_ms)
 		msleep(ihid_elan->chip_data->post_power_delay_ms);
@@ -60,6 +61,15 @@ static int elan_i2c_hid_power_up(struct i2chid_ops *ops)
 		msleep(ihid_elan->chip_data->post_gpio_reset_on_delay_ms);
 
 	return 0;
+
+err_disable_vcc33:
+	if (ihid_elan->vcc33)
+		regulator_disable(ihid_elan->vcc33);
+err_deassert_reset:
+	if (ihid_elan->no_reset_on_power_off)
+		gpiod_set_value_cansleep(ihid_elan->reset_gpio, 0);
+
+	return ret;
 }
 
 static void elan_i2c_hid_power_down(struct i2chid_ops *ops)
@@ -67,7 +77,14 @@ static void elan_i2c_hid_power_down(struct i2chid_ops *ops)
 	struct i2c_hid_of_elan *ihid_elan =
 		container_of(ops, struct i2c_hid_of_elan, ops);
 
-	gpiod_set_value_cansleep(ihid_elan->reset_gpio, 1);
+	/*
+	 * Do not assert reset when the hardware allows for it to remain
+	 * deasserted regardless of the state of the (shared) power supply to
+	 * avoid wasting power when the supply is left on.
+	 */
+	if (!ihid_elan->no_reset_on_power_off)
+		gpiod_set_value_cansleep(ihid_elan->reset_gpio, 1);
+
 	if (ihid_elan->chip_data->post_gpio_reset_off_delay_ms)
 		msleep(ihid_elan->chip_data->post_gpio_reset_off_delay_ms);
 
@@ -79,6 +96,7 @@ static void elan_i2c_hid_power_down(struct i2chid_ops *ops)
 static int i2c_hid_of_elan_probe(struct i2c_client *client)
 {
 	struct i2c_hid_of_elan *ihid_elan;
+	int ret;
 
 	ihid_elan = devm_kzalloc(&client->dev, sizeof(*ihid_elan), GFP_KERNEL);
 	if (!ihid_elan)
@@ -93,21 +111,38 @@ static int i2c_hid_of_elan_probe(struct i2c_client *client)
 	if (IS_ERR(ihid_elan->reset_gpio))
 		return PTR_ERR(ihid_elan->reset_gpio);
 
+	ihid_elan->no_reset_on_power_off = of_property_read_bool(client->dev.of_node,
+						"no-reset-on-power-off");
+
 	ihid_elan->vccio = devm_regulator_get(&client->dev, "vccio");
-	if (IS_ERR(ihid_elan->vccio))
-		return PTR_ERR(ihid_elan->vccio);
+	if (IS_ERR(ihid_elan->vccio)) {
+		ret = PTR_ERR(ihid_elan->vccio);
+		goto err_deassert_reset;
+	}
 
 	ihid_elan->chip_data = device_get_match_data(&client->dev);
 
 	if (ihid_elan->chip_data->main_supply_name) {
 		ihid_elan->vcc33 = devm_regulator_get(&client->dev,
 						      ihid_elan->chip_data->main_supply_name);
-		if (IS_ERR(ihid_elan->vcc33))
-			return PTR_ERR(ihid_elan->vcc33);
+		if (IS_ERR(ihid_elan->vcc33)) {
+			ret = PTR_ERR(ihid_elan->vcc33);
+			goto err_deassert_reset;
+		}
 	}
 
-	return i2c_hid_core_probe(client, &ihid_elan->ops,
-				  ihid_elan->chip_data->hid_descriptor_address, 0);
+	ret = i2c_hid_core_probe(client, &ihid_elan->ops,
+				 ihid_elan->chip_data->hid_descriptor_address, 0);
+	if (ret)
+		goto err_deassert_reset;
+
+	return 0;
+
+err_deassert_reset:
+	if (ihid_elan->no_reset_on_power_off)
+		gpiod_set_value_cansleep(ihid_elan->reset_gpio, 0);
+
+	return ret;
 }
 
 static const struct elan_i2c_hid_chip_data elan_ekth6915_chip_data = {
-- 
2.43.2


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

* [PATCH v2 5/7] arm64: dts: qcom: sc8280xp-x13s: fix touchscreen power on
  2024-05-07 14:48 [PATCH v2 0/7] HID/arm64: dts: qcom: sc8280xp-x13s: fix touchscreen power on Johan Hovold
                   ` (3 preceding siblings ...)
  2024-05-07 14:48 ` [PATCH v2 4/7] HID: i2c-hid: elan: fix reset suspend current leakage Johan Hovold
@ 2024-05-07 14:48 ` Johan Hovold
  2024-05-07 14:48 ` [PATCH v2 6/7] arm64: dts: qcom: sc8280xp-crd: use external pull up for touch reset Johan Hovold
  2024-05-07 14:48 ` [PATCH v2 7/7] arm64: defconfig: enable Elan i2c-hid driver Johan Hovold
  6 siblings, 0 replies; 14+ messages in thread
From: Johan Hovold @ 2024-05-07 14:48 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Bjorn Andersson
  Cc: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Konrad Dybcio, Linus Walleij, Douglas Anderson, linux-input,
	devicetree, linux-arm-msm, linux-kernel, Johan Hovold, stable,
	Steev Klimaszewski

The Elan eKTH5015M touch controller on the X13s requires a 300 ms delay
before sending commands after having deasserted reset during power on.

Switch to the Elan specific binding so that the OS can determine the
required power-on sequence and make sure that the controller is always
detected during boot.

Note that the always-on 1.8 V supply (s10b) is not used by the
controller directly and should not be described.

Fixes: 32c231385ed4 ("arm64: dts: qcom: sc8280xp: add Lenovo Thinkpad X13s devicetree")
Cc: stable@vger.kernel.org	# 6.0
Tested-by: Steev Klimaszewski <steev@kali.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 .../dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts    | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
index 569add4ebfab..98c1b75513be 100644
--- a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
+++ b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
@@ -653,15 +653,16 @@ &i2c4 {
 
 	status = "okay";
 
-	/* FIXME: verify */
 	touchscreen@10 {
-		compatible = "hid-over-i2c";
+		compatible = "elan,ekth5015m", "elan,ekth6915";
 		reg = <0x10>;
 
-		hid-descr-addr = <0x1>;
 		interrupts-extended = <&tlmm 175 IRQ_TYPE_LEVEL_LOW>;
-		vdd-supply = <&vreg_misc_3p3>;
-		vddl-supply = <&vreg_s10b>;
+		reset-gpios = <&tlmm 99 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>;
+		no-reset-on-power-off;
+
+		vcc33-supply = <&vreg_misc_3p3>;
+		vccio-supply = <&vreg_misc_3p3>;
 
 		pinctrl-names = "default";
 		pinctrl-0 = <&ts0_default>;
@@ -1507,8 +1508,8 @@ int-n-pins {
 		reset-n-pins {
 			pins = "gpio99";
 			function = "gpio";
-			output-high;
-			drive-strength = <16>;
+			drive-strength = <2>;
+			bias-disable;
 		};
 	};
 
-- 
2.43.2


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

* [PATCH v2 6/7] arm64: dts: qcom: sc8280xp-crd: use external pull up for touch reset
  2024-05-07 14:48 [PATCH v2 0/7] HID/arm64: dts: qcom: sc8280xp-x13s: fix touchscreen power on Johan Hovold
                   ` (4 preceding siblings ...)
  2024-05-07 14:48 ` [PATCH v2 5/7] arm64: dts: qcom: sc8280xp-x13s: fix touchscreen power on Johan Hovold
@ 2024-05-07 14:48 ` Johan Hovold
  2024-05-07 14:48 ` [PATCH v2 7/7] arm64: defconfig: enable Elan i2c-hid driver Johan Hovold
  6 siblings, 0 replies; 14+ messages in thread
From: Johan Hovold @ 2024-05-07 14:48 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Bjorn Andersson
  Cc: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Konrad Dybcio, Linus Walleij, Douglas Anderson, linux-input,
	devicetree, linux-arm-msm, linux-kernel, Johan Hovold

The touch controller reset line is currently not described by the
devicetree except in the pin configuration which is used to deassert
reset.

As the reset line has an external pull up to an always-on rail there is
no need to drive the pin high so just leave it configured as an input
and disable the internal pull down.

Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 arch/arm64/boot/dts/qcom/sc8280xp-crd.dts | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-crd.dts b/arch/arm64/boot/dts/qcom/sc8280xp-crd.dts
index 41215567b3ae..372b35fb844f 100644
--- a/arch/arm64/boot/dts/qcom/sc8280xp-crd.dts
+++ b/arch/arm64/boot/dts/qcom/sc8280xp-crd.dts
@@ -977,8 +977,7 @@ int-n-pins {
 		reset-n-pins {
 			pins = "gpio99";
 			function = "gpio";
-			output-high;
-			drive-strength = <16>;
+			bias-disable;
 		};
 	};
 
-- 
2.43.2


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

* [PATCH v2 7/7] arm64: defconfig: enable Elan i2c-hid driver
  2024-05-07 14:48 [PATCH v2 0/7] HID/arm64: dts: qcom: sc8280xp-x13s: fix touchscreen power on Johan Hovold
                   ` (5 preceding siblings ...)
  2024-05-07 14:48 ` [PATCH v2 6/7] arm64: dts: qcom: sc8280xp-crd: use external pull up for touch reset Johan Hovold
@ 2024-05-07 14:48 ` Johan Hovold
  6 siblings, 0 replies; 14+ messages in thread
From: Johan Hovold @ 2024-05-07 14:48 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Bjorn Andersson
  Cc: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Konrad Dybcio, Linus Walleij, Douglas Anderson, linux-input,
	devicetree, linux-arm-msm, linux-kernel, Johan Hovold

Enable the Elan i2c-hid driver which is needed for the touchscreen on
machines like the Lenovo ThinkPad X13s.

Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index ac6fb3de1e3a..56fb9725d7c0 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -1023,6 +1023,7 @@ CONFIG_SND_AUDIO_GRAPH_CARD2=m
 CONFIG_HID_MULTITOUCH=m
 CONFIG_I2C_HID_ACPI=m
 CONFIG_I2C_HID_OF=m
+CONFIG_I2C_HID_OF_ELAN=m
 CONFIG_USB=y
 CONFIG_USB_OTG=y
 CONFIG_USB_XHCI_HCD=y
-- 
2.43.2


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

* Re: [PATCH v2 3/7] dt-bindings: HID: i2c-hid: elan: add 'no-reset-on-power-off' property
  2024-05-07 14:48 ` [PATCH v2 3/7] dt-bindings: HID: i2c-hid: elan: add 'no-reset-on-power-off' property Johan Hovold
@ 2024-05-08  7:29   ` Krzysztof Kozlowski
  2024-05-27 13:01   ` Linus Walleij
  1 sibling, 0 replies; 14+ messages in thread
From: Krzysztof Kozlowski @ 2024-05-08  7:29 UTC (permalink / raw)
  To: Johan Hovold, Jiri Kosina, Benjamin Tissoires, Bjorn Andersson
  Cc: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Konrad Dybcio, Linus Walleij, Douglas Anderson, linux-input,
	devicetree, linux-arm-msm, linux-kernel

On 07/05/2024 16:48, Johan Hovold wrote:
> When the power supply is shared with other peripherals the reset line
> can be wired in such a way that it can remain deasserted regardless of
> whether the supply is on or not.
> 
> This is important as it can be used to avoid holding the controller in
> reset for extended periods of time when it remains powered, something
> which can lead to increased power consumption. Leaving reset deasserted
> also avoids leaking current through the reset circuitry pull-up
> resistors.
> 
> Add a new 'no-reset-on-power-off' devicetree property which can be used
> by the OS to determine when reset needs to be asserted on power down.
> 
> Note that this property can also be used when the supply cannot be
> turned off by the OS at all.
> 
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof


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

* Re: [PATCH v2 4/7] HID: i2c-hid: elan: fix reset suspend current leakage
  2024-05-07 14:48 ` [PATCH v2 4/7] HID: i2c-hid: elan: fix reset suspend current leakage Johan Hovold
@ 2024-05-10 23:36   ` Doug Anderson
  2024-05-20 11:44     ` Johan Hovold
  0 siblings, 1 reply; 14+ messages in thread
From: Doug Anderson @ 2024-05-10 23:36 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Jiri Kosina, Benjamin Tissoires, Bjorn Andersson,
	Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Konrad Dybcio, Linus Walleij, linux-input, devicetree,
	linux-arm-msm, linux-kernel, stable, Steev Klimaszewski

Hi,

On Tue, May 7, 2024 at 7:48 AM Johan Hovold <johan+linaro@kernel.org> wrote:
>
> @@ -40,17 +41,17 @@ static int elan_i2c_hid_power_up(struct i2chid_ops *ops)
>                 container_of(ops, struct i2c_hid_of_elan, ops);
>         int ret;
>
> +       gpiod_set_value_cansleep(ihid_elan->reset_gpio, 1);

Could probably use a comment above it saying that this is important
when we have "no_reset_on_power_off" and doesn't do anything bad when
we don't so we can just do it unconditionally.


> +
>         if (ihid_elan->vcc33) {
>                 ret = regulator_enable(ihid_elan->vcc33);
>                 if (ret)
> -                       return ret;
> +                       goto err_deassert_reset;
>         }
>
>         ret = regulator_enable(ihid_elan->vccio);
> -       if (ret) {
> -               regulator_disable(ihid_elan->vcc33);
> -               return ret;
> -       }
> +       if (ret)
> +               goto err_disable_vcc33;
>
>         if (ihid_elan->chip_data->post_power_delay_ms)
>                 msleep(ihid_elan->chip_data->post_power_delay_ms);
> @@ -60,6 +61,15 @@ static int elan_i2c_hid_power_up(struct i2chid_ops *ops)
>                 msleep(ihid_elan->chip_data->post_gpio_reset_on_delay_ms);
>
>         return 0;
> +
> +err_disable_vcc33:
> +       if (ihid_elan->vcc33)
> +               regulator_disable(ihid_elan->vcc33);
> +err_deassert_reset:
> +       if (ihid_elan->no_reset_on_power_off)
> +               gpiod_set_value_cansleep(ihid_elan->reset_gpio, 0);

Small nit about the error label: it sounds as if when you go here you
_will_ deassert reset when in actuality you might or might not
(depending on no_reset_on_power_off). Personally I prefer to label
error jumps based on things I've done instead of things that the error
jump needs to do, so you could call them "err_enabled_vcc33" and
"err_asserted_reset"...

I don't feel that strongly about it, though, so if you love the label
you have then no need to change it.


> @@ -67,7 +77,14 @@ static void elan_i2c_hid_power_down(struct i2chid_ops *ops)
>         struct i2c_hid_of_elan *ihid_elan =
>                 container_of(ops, struct i2c_hid_of_elan, ops);
>
> -       gpiod_set_value_cansleep(ihid_elan->reset_gpio, 1);
> +       /*
> +        * Do not assert reset when the hardware allows for it to remain
> +        * deasserted regardless of the state of the (shared) power supply to
> +        * avoid wasting power when the supply is left on.
> +        */
> +       if (!ihid_elan->no_reset_on_power_off)
> +               gpiod_set_value_cansleep(ihid_elan->reset_gpio, 1);
> +
>         if (ihid_elan->chip_data->post_gpio_reset_off_delay_ms)
>                 msleep(ihid_elan->chip_data->post_gpio_reset_off_delay_ms);

Shouldn't  the above two lines be inside the "if
(!ihid_elan->no_reset_on_power_off)" test? If you're not setting the
reset GPIO then you don't need to do the delay, right?


> @@ -79,6 +96,7 @@ static void elan_i2c_hid_power_down(struct i2chid_ops *ops)
>  static int i2c_hid_of_elan_probe(struct i2c_client *client)
>  {
>         struct i2c_hid_of_elan *ihid_elan;
> +       int ret;
>
>         ihid_elan = devm_kzalloc(&client->dev, sizeof(*ihid_elan), GFP_KERNEL);
>         if (!ihid_elan)
> @@ -93,21 +111,38 @@ static int i2c_hid_of_elan_probe(struct i2c_client *client)
>         if (IS_ERR(ihid_elan->reset_gpio))
>                 return PTR_ERR(ihid_elan->reset_gpio);
>
> +       ihid_elan->no_reset_on_power_off = of_property_read_bool(client->dev.of_node,
> +                                               "no-reset-on-power-off");

Personally, I'd rather you query for the property before you request
the GPIO and then request the GPIO in the "powered off" state just to
keep everything in the most consistent state possible.


-Doug

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

* Re: [PATCH v2 4/7] HID: i2c-hid: elan: fix reset suspend current leakage
  2024-05-10 23:36   ` Doug Anderson
@ 2024-05-20 11:44     ` Johan Hovold
  2024-05-20 11:52       ` Johan Hovold
  0 siblings, 1 reply; 14+ messages in thread
From: Johan Hovold @ 2024-05-20 11:44 UTC (permalink / raw)
  To: Doug Anderson
  Cc: Johan Hovold, Jiri Kosina, Benjamin Tissoires, Bjorn Andersson,
	Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Konrad Dybcio, Linus Walleij, linux-input, devicetree,
	linux-arm-msm, linux-kernel, stable, Steev Klimaszewski

Hi Doug,

and sorry about the late reply. Was travelling last week.

On Fri, May 10, 2024 at 04:36:08PM -0700, Doug Anderson wrote:
> On Tue, May 7, 2024 at 7:48 AM Johan Hovold <johan+linaro@kernel.org> wrote:
> >
> > @@ -40,17 +41,17 @@ static int elan_i2c_hid_power_up(struct i2chid_ops *ops)
> >                 container_of(ops, struct i2c_hid_of_elan, ops);
> >         int ret;
> >
> > +       gpiod_set_value_cansleep(ihid_elan->reset_gpio, 1);
> 
> Could probably use a comment above it saying that this is important
> when we have "no_reset_on_power_off" and doesn't do anything bad when
> we don't so we can just do it unconditionally.

Possibly, but I'd prefer not to add comments for things like this, which
should be apparent from just looking at the code. And explicitly
asserting reset before deasserting it is not unusual in any way.

> > +
> >         if (ihid_elan->vcc33) {
> >                 ret = regulator_enable(ihid_elan->vcc33);
> >                 if (ret)
> > -                       return ret;
> > +                       goto err_deassert_reset;
> >         }
> >
> >         ret = regulator_enable(ihid_elan->vccio);
> > -       if (ret) {
> > -               regulator_disable(ihid_elan->vcc33);
> > -               return ret;
> > -       }
> > +       if (ret)
> > +               goto err_disable_vcc33;
> >
> >         if (ihid_elan->chip_data->post_power_delay_ms)
> >                 msleep(ihid_elan->chip_data->post_power_delay_ms);
> > @@ -60,6 +61,15 @@ static int elan_i2c_hid_power_up(struct i2chid_ops *ops)
> >                 msleep(ihid_elan->chip_data->post_gpio_reset_on_delay_ms);
> >
> >         return 0;
> > +
> > +err_disable_vcc33:
> > +       if (ihid_elan->vcc33)
> > +               regulator_disable(ihid_elan->vcc33);
> > +err_deassert_reset:
> > +       if (ihid_elan->no_reset_on_power_off)
> > +               gpiod_set_value_cansleep(ihid_elan->reset_gpio, 0);
> 
> Small nit about the error label: it sounds as if when you go here you
> _will_ deassert reset when in actuality you might or might not
> (depending on no_reset_on_power_off).

Yes, this is similar to how err_disable_vcc33 may or may not disable the
optional regulator.

> Personally I prefer to label
> error jumps based on things I've done instead of things that the error
> jump needs to do, so you could call them "err_enabled_vcc33" and
> "err_asserted_reset"...

Naming labels after what they do is less error prone and also explicitly
recommended by the coding style.

> I don't feel that strongly about it, though, so if you love the label
> you have then no need to change it.

So I'd prefer keeping things this way.
 
> > @@ -67,7 +77,14 @@ static void elan_i2c_hid_power_down(struct i2chid_ops *ops)
> >         struct i2c_hid_of_elan *ihid_elan =
> >                 container_of(ops, struct i2c_hid_of_elan, ops);
> >
> > -       gpiod_set_value_cansleep(ihid_elan->reset_gpio, 1);
> > +       /*
> > +        * Do not assert reset when the hardware allows for it to remain
> > +        * deasserted regardless of the state of the (shared) power supply to
> > +        * avoid wasting power when the supply is left on.
> > +        */
> > +       if (!ihid_elan->no_reset_on_power_off)
> > +               gpiod_set_value_cansleep(ihid_elan->reset_gpio, 1);
> > +
> >         if (ihid_elan->chip_data->post_gpio_reset_off_delay_ms)
> >                 msleep(ihid_elan->chip_data->post_gpio_reset_off_delay_ms);
> 
> Shouldn't  the above two lines be inside the "if
> (!ihid_elan->no_reset_on_power_off)" test? If you're not setting the
> reset GPIO then you don't need to do the delay, right?

Yes, I guess you're right. The off-delay is weird and not normally used,
but apparently it is needed by some panel-follower use case. AFAICT it's
not even related to the reset line, just a hack to add a delay before
the panel is reset by some other driver (see f2f43bf15d7a ("HID:
i2c-hid: elan: Add ili9882t timing")).

I think that's why I just looked the other way and left this little
oddity here unchanged.

> > @@ -79,6 +96,7 @@ static void elan_i2c_hid_power_down(struct i2chid_ops *ops)
> >  static int i2c_hid_of_elan_probe(struct i2c_client *client)
> >  {
> >         struct i2c_hid_of_elan *ihid_elan;
> > +       int ret;
> >
> >         ihid_elan = devm_kzalloc(&client->dev, sizeof(*ihid_elan), GFP_KERNEL);
> >         if (!ihid_elan)
> > @@ -93,21 +111,38 @@ static int i2c_hid_of_elan_probe(struct i2c_client *client)
> >         if (IS_ERR(ihid_elan->reset_gpio))
> >                 return PTR_ERR(ihid_elan->reset_gpio);
> >
> > +       ihid_elan->no_reset_on_power_off = of_property_read_bool(client->dev.of_node,
> > +                                               "no-reset-on-power-off");
> 
> Personally, I'd rather you query for the property before you request
> the GPIO and then request the GPIO in the "powered off" state just to
> keep everything in the most consistent state possible.

No, I don't know what state the reset line is in before the driver
probes. So either I leave it unchanged as I did in v1 or I assert it
here unconditionally as I do in v2 (e.g. to avoid deasserting reset
before the supply is stable).

Johan

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

* Re: [PATCH v2 4/7] HID: i2c-hid: elan: fix reset suspend current leakage
  2024-05-20 11:44     ` Johan Hovold
@ 2024-05-20 11:52       ` Johan Hovold
  2024-05-20 15:38         ` Doug Anderson
  0 siblings, 1 reply; 14+ messages in thread
From: Johan Hovold @ 2024-05-20 11:52 UTC (permalink / raw)
  To: Doug Anderson
  Cc: Johan Hovold, Jiri Kosina, Benjamin Tissoires, Bjorn Andersson,
	Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Konrad Dybcio, Linus Walleij, linux-input, devicetree,
	linux-arm-msm, linux-kernel, stable, Steev Klimaszewski

On Mon, May 20, 2024 at 01:44:06PM +0200, Johan Hovold wrote:
> On Fri, May 10, 2024 at 04:36:08PM -0700, Doug Anderson wrote:
> > On Tue, May 7, 2024 at 7:48 AM Johan Hovold <johan+linaro@kernel.org> wrote:

> > > @@ -67,7 +77,14 @@ static void elan_i2c_hid_power_down(struct i2chid_ops *ops)
> > >         struct i2c_hid_of_elan *ihid_elan =
> > >                 container_of(ops, struct i2c_hid_of_elan, ops);
> > >
> > > -       gpiod_set_value_cansleep(ihid_elan->reset_gpio, 1);
> > > +       /*
> > > +        * Do not assert reset when the hardware allows for it to remain
> > > +        * deasserted regardless of the state of the (shared) power supply to
> > > +        * avoid wasting power when the supply is left on.
> > > +        */
> > > +       if (!ihid_elan->no_reset_on_power_off)
> > > +               gpiod_set_value_cansleep(ihid_elan->reset_gpio, 1);
> > > +
> > >         if (ihid_elan->chip_data->post_gpio_reset_off_delay_ms)
> > >                 msleep(ihid_elan->chip_data->post_gpio_reset_off_delay_ms);
> > 
> > Shouldn't  the above two lines be inside the "if
> > (!ihid_elan->no_reset_on_power_off)" test? If you're not setting the
> > reset GPIO then you don't need to do the delay, right?
> 
> Yes, I guess you're right. The off-delay is weird and not normally used,
> but apparently it is needed by some panel-follower use case. AFAICT it's
> not even related to the reset line, just a hack to add a delay before
> the panel is reset by some other driver (see f2f43bf15d7a ("HID:
> i2c-hid: elan: Add ili9882t timing")).
> 
> I think that's why I just looked the other way and left this little
> oddity here unchanged.

Hit send too soon.

Since this hack does not appear to be related to the reset line, I think
it's correct to not have it depend on whether the reset line is asserted
or not (e.g. as there could be 'panel-followers' with
'no_reset_on_power_off'):

	 The datasheet specifies there should be 60ms between touch SDA
	 sleep and panel RESX. Doug's series[1] allows panels and
	 touchscreens to power on/off together, so we can add the 65 ms
	 delay in i2c_hid_core_suspend before panel_unprepare.

The power-off delay variable should probably be renamed, but that's a
separate change.

So I think v2 of this series is good to go.

Johan

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

* Re: [PATCH v2 4/7] HID: i2c-hid: elan: fix reset suspend current leakage
  2024-05-20 11:52       ` Johan Hovold
@ 2024-05-20 15:38         ` Doug Anderson
  0 siblings, 0 replies; 14+ messages in thread
From: Doug Anderson @ 2024-05-20 15:38 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Johan Hovold, Jiri Kosina, Benjamin Tissoires, Bjorn Andersson,
	Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Konrad Dybcio, Linus Walleij, linux-input, devicetree,
	linux-arm-msm, linux-kernel, stable, Steev Klimaszewski

Hi,

On Mon, May 20, 2024 at 4:52 AM Johan Hovold <johan@kernel.org> wrote:
>
> On Mon, May 20, 2024 at 01:44:06PM +0200, Johan Hovold wrote:
> > On Fri, May 10, 2024 at 04:36:08PM -0700, Doug Anderson wrote:
> > > On Tue, May 7, 2024 at 7:48 AM Johan Hovold <johan+linaro@kernel.org> wrote:
>
> > > > @@ -67,7 +77,14 @@ static void elan_i2c_hid_power_down(struct i2chid_ops *ops)
> > > >         struct i2c_hid_of_elan *ihid_elan =
> > > >                 container_of(ops, struct i2c_hid_of_elan, ops);
> > > >
> > > > -       gpiod_set_value_cansleep(ihid_elan->reset_gpio, 1);
> > > > +       /*
> > > > +        * Do not assert reset when the hardware allows for it to remain
> > > > +        * deasserted regardless of the state of the (shared) power supply to
> > > > +        * avoid wasting power when the supply is left on.
> > > > +        */
> > > > +       if (!ihid_elan->no_reset_on_power_off)
> > > > +               gpiod_set_value_cansleep(ihid_elan->reset_gpio, 1);
> > > > +
> > > >         if (ihid_elan->chip_data->post_gpio_reset_off_delay_ms)
> > > >                 msleep(ihid_elan->chip_data->post_gpio_reset_off_delay_ms);
> > >
> > > Shouldn't  the above two lines be inside the "if
> > > (!ihid_elan->no_reset_on_power_off)" test? If you're not setting the
> > > reset GPIO then you don't need to do the delay, right?
> >
> > Yes, I guess you're right. The off-delay is weird and not normally used,
> > but apparently it is needed by some panel-follower use case. AFAICT it's
> > not even related to the reset line, just a hack to add a delay before
> > the panel is reset by some other driver (see f2f43bf15d7a ("HID:
> > i2c-hid: elan: Add ili9882t timing")).
> >
> > I think that's why I just looked the other way and left this little
> > oddity here unchanged.
>
> Hit send too soon.
>
> Since this hack does not appear to be related to the reset line, I think
> it's correct to not have it depend on whether the reset line is asserted
> or not (e.g. as there could be 'panel-followers' with
> 'no_reset_on_power_off'):
>
>          The datasheet specifies there should be 60ms between touch SDA
>          sleep and panel RESX. Doug's series[1] allows panels and
>          touchscreens to power on/off together, so we can add the 65 ms
>          delay in i2c_hid_core_suspend before panel_unprepare.
>
> The power-off delay variable should probably be renamed, but that's a
> separate change.
>
> So I think v2 of this series is good to go.

Sure. As I think we've seen in the past, my choice of bikeshed paint
color seems to be quite different than yours, but nothing here seems
like it needs to block landing, so:

Reviewed-by: Douglas Anderson <dianders@chromium.org>

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

* Re: [PATCH v2 3/7] dt-bindings: HID: i2c-hid: elan: add 'no-reset-on-power-off' property
  2024-05-07 14:48 ` [PATCH v2 3/7] dt-bindings: HID: i2c-hid: elan: add 'no-reset-on-power-off' property Johan Hovold
  2024-05-08  7:29   ` Krzysztof Kozlowski
@ 2024-05-27 13:01   ` Linus Walleij
  1 sibling, 0 replies; 14+ messages in thread
From: Linus Walleij @ 2024-05-27 13:01 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Jiri Kosina, Benjamin Tissoires, Bjorn Andersson,
	Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Konrad Dybcio, Douglas Anderson, linux-input, devicetree,
	linux-arm-msm, linux-kernel

On Tue, May 7, 2024 at 4:48 PM Johan Hovold <johan+linaro@kernel.org> wrote:

> When the power supply is shared with other peripherals the reset line
> can be wired in such a way that it can remain deasserted regardless of
> whether the supply is on or not.
>
> This is important as it can be used to avoid holding the controller in
> reset for extended periods of time when it remains powered, something
> which can lead to increased power consumption. Leaving reset deasserted
> also avoids leaking current through the reset circuitry pull-up
> resistors.
>
> Add a new 'no-reset-on-power-off' devicetree property which can be used
> by the OS to determine when reset needs to be asserted on power down.
>
> Note that this property can also be used when the supply cannot be
> turned off by the OS at all.
>
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

end of thread, other threads:[~2024-05-27 13:02 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-07 14:48 [PATCH v2 0/7] HID/arm64: dts: qcom: sc8280xp-x13s: fix touchscreen power on Johan Hovold
2024-05-07 14:48 ` [PATCH v2 1/7] dt-bindings: HID: i2c-hid: add dedicated Ilitek ILI2901 schema Johan Hovold
2024-05-07 14:48 ` [PATCH v2 2/7] dt-bindings: HID: i2c-hid: elan: add Elan eKTH5015M Johan Hovold
2024-05-07 14:48 ` [PATCH v2 3/7] dt-bindings: HID: i2c-hid: elan: add 'no-reset-on-power-off' property Johan Hovold
2024-05-08  7:29   ` Krzysztof Kozlowski
2024-05-27 13:01   ` Linus Walleij
2024-05-07 14:48 ` [PATCH v2 4/7] HID: i2c-hid: elan: fix reset suspend current leakage Johan Hovold
2024-05-10 23:36   ` Doug Anderson
2024-05-20 11:44     ` Johan Hovold
2024-05-20 11:52       ` Johan Hovold
2024-05-20 15:38         ` Doug Anderson
2024-05-07 14:48 ` [PATCH v2 5/7] arm64: dts: qcom: sc8280xp-x13s: fix touchscreen power on Johan Hovold
2024-05-07 14:48 ` [PATCH v2 6/7] arm64: dts: qcom: sc8280xp-crd: use external pull up for touch reset Johan Hovold
2024-05-07 14:48 ` [PATCH v2 7/7] arm64: defconfig: enable Elan i2c-hid driver Johan Hovold

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