Skip to contentSkip to conversation

input: touchscreen: edt-ft5x06: make wakeup source behavior configurable

PATCH New Daniel Mack 4 participants 12 messages May 17, 2018 – May 25, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover input: touchscreen: edt-ft5x06: make wakeup source behavior configurable

Hi,

I have a platform that features an edt-ft5x06 touch panel and that doesn't want to wake on touch screen activity.

Here's a trivial series of patches that make the edt-ft5x06 driver only act as wakeup source when requested through device properties or DTS.

The third patch changes the default in two DTS files that use this driver.

I guess the first two patches should go through the input tree, while the third can be picked by the IMX people. There are no compile-time dependencies, so the order doesn't matter.

Thanks,
Daniel

v1 ? v2:
* simply drop device_init_wakeup() as the I2C core does handles the wakeup-source property already (1/3)
* add a delay after reset deassertion at resume time (2/3)
* no changes in the DTS patch (3/3)

Daniel Mack (3):
input: touchscreen: edt-ft5x06: don't make device a wakeup source by
default
input: touchscreen: edt-ft5x06: assert reset during suspend
ARM: dts: imx28/imx53: enable edt-ft5x06 wakeup source

 .../bindings/input/touchscreen/edt-ft5x06.txt      |  3 +++
 arch/arm/boot/dts/imx28-tx28.dts                   |  1 +
 arch/arm/boot/dts/imx53-tx53-x03x.dts              |  1 +
 drivers/input/touchscreen/edt-ft5x06.c             | 27 +++++++++++++++++-----
 4 files changed, 26 insertions(+), 6 deletions(-)
Signature · 1 line
2.14.3
#1 lore raw

PATCH v2 1/3 input: touchscreen: edt-ft5x06: don't make device a wakeup source by default

Allow configuring the device as wakeup source through device properties, as not all platforms want to wake up on touch screen activity.

The I2C core automatically reads the "wakeup-source" DT property to configure a device's wakeup capability, and board supports files can set I2C_CLIENT_WAKE in the flags.

---
 Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt | 3 +++
 drivers/input/touchscreen/edt-ft5x06.c                             | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt +3 -0
index 025cf8c9324a..83f792d4d88c 100644
@@ -52,6 +52,8 @@ Optional properties:
  - touchscreen-inverted-y  : See touchscreen.txt
  - touchscreen-swapped-x-y : See touchscreen.txt
 
+ - wakeup-source: touchscreen acts as wakeup source
+
 Example:
 	polytouch: edt-ft5x06 at 38 {
 		compatible = "edt,edt-ft5406", "edt,edt-ft5x06";
@@ -62,4 +64,5 @@ Example:
 		interrupts = <5 IRQ_TYPE_EDGE_FALLING>;
 		reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>;
 		wake-gpios = <&gpio4 9 GPIO_ACTIVE_HIGH>;
+		wakeup-source;
 	};
drivers/input/touchscreen/edt-ft5x06.c +0 -1
index 5bf63f76ddda..e18a2f215500 100644
@@ -1007,7 +1007,6 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
 		goto err_remove_attrs;
 
 	edt_ft5x06_ts_prepare_debugfs(tsdata, dev_driver_string(&client->dev));
-	device_init_wakeup(&client->dev, 1);
 
 	dev_dbg(&client->dev,
 		"EDT FT5x06 initialized: IRQ %d, WAKE pin %d, Reset pin %d.\n",
Signature · 1 line
2.14.3
maintainer
#2 lore raw

PATCH v2 1/3 input: touchscreen: edt-ft5x06: don't make device a wakeup source by default

Quoted 6 lines · Daniel Mack

Allow configuring the device as wakeup source through device properties, as not all platforms want to wake up on touch screen activity.

The I2C core automatically reads the "wakeup-source" DT property to configure a device's wakeup capability, and board supports files can set I2C_CLIENT_WAKE in the flags.

This will break wake-up on working systems. Looks like mostly i.MX, but there's one AM437x board. If that board doesn't care, then it is up to Shawn.

Rob

#3 lore raw

PATCH v2 1/3 input: touchscreen: edt-ft5x06: don't make device a wakeup source by default

Quoted 11 lines · Rob Herring
Quoted 6 lines · Daniel Mack

Allow configuring the device as wakeup source through device properties, as not all platforms want to wake up on touch screen activity.

The I2C core automatically reads the "wakeup-source" DT property to configure a device's wakeup capability, and board supports files can set I2C_CLIENT_WAKE in the flags.

This will break wake-up on working systems. Looks like mostly i.MX, but there's one AM437x board. If that board doesn't care, then it is up to Shawn.

I added the property to the dts files, but as Dmitry pointed out, I missed some. Sorry for that.

Thanks,
Daniel

maintainer
#4 lore raw

PATCH v2 1/3 input: touchscreen: edt-ft5x06: don't make device a wakeup source by default

Quoted 13 lines · Daniel Mack
Quoted 12 lines · Rob Herring
Quoted 8 lines · Daniel Mack

Allow configuring the device as wakeup source through device properties, as
not all platforms want to wake up on touch screen activity.

The I2C core automatically reads the "wakeup-source" DT property to configure a device's wakeup capability, and board supports files can set I2C_CLIENT_WAKE in the flags.

Quoted 7 lines
Quoted 3 lines

This will break wake-up on working systems. Looks like mostly i.MX, but there's one AM437x board. If that board doesn't care, then it is up to Shawn.

I added the property to the dts files, but as Dmitry pointed out, I missed some. Sorry for that.

Just adding the property to dts files doesn't fix the compatibility problem. If a user uses an existing dtb (before this change) with a new kernel (after this change), then wakeup will stop working.

Rob

maintainer
#5 lore raw

PATCH v2 1/3 input: touchscreen: edt-ft5x06: don't make device a wakeup source by default

Quoted 19 lines · Rob Herring
Quoted 18 lines · Daniel Mack
Quoted 15 lines · Rob Herring
Quoted 8 lines · Daniel Mack

Allow configuring the device as wakeup source through device properties, as
not all platforms want to wake up on touch screen activity.

The I2C core automatically reads the "wakeup-source" DT property to configure a device's wakeup capability, and board supports files can set I2C_CLIENT_WAKE in the flags.

This will break wake-up on working systems. Looks like mostly i.MX, but there's one AM437x board. If that board doesn't care, then it is up to Shawn.

Quoted 6 lines
Quoted 2 lines

I added the property to the dts files, but as Dmitry pointed out, I missed some. Sorry for that.

Just adding the property to dts files doesn't fix the compatibility problem. If a user uses an existing dtb (before this change) with a new kernel (after this change), then wakeup will stop working.

Is this a practical problem though? Do we know of any products with this touch panel that use DTS not distributed with the kernel?

Signature · 1 line
Dmitry
maintainer
#6 lore raw

PATCH v2 1/3 input: touchscreen: edt-ft5x06: don't make device a wakeup source by default

Quoted 23 lines · Dmitry Torokhov
Quoted 22 lines · Rob Herring
Quoted 20 lines · Daniel Mack
Quoted 7 lines · Rob Herring
Quoted 5 lines · Daniel Mack

Allow configuring the device as wakeup source through device properties, as
not all platforms want to wake up on touch screen activity.

Quoted 8 lines
Quoted 3 lines

The I2C core automatically reads the "wakeup-source" DT property to configure a device's wakeup capability, and board supports files can set I2C_CLIENT_WAKE in the flags.

This will break wake-up on working systems. Looks like mostly i.MX, but there's one AM437x board. If that board doesn't care, then it is up to Shawn.

I added the property to the dts files, but as Dmitry pointed out, I missed some. Sorry for that.

Quoted 6 lines
Quoted 3 lines

Just adding the property to dts files doesn't fix the compatibility problem. If a user uses an existing dtb (before this change) with a new kernel (after this change), then wakeup will stop working.

Is this a practical problem though? Do we know of any products with this touch panel that use DTS not distributed with the kernel?

Distribution of dts with kernel is irrelevant. It is how the dtb's are handled that matters. You still need to ask in tree users.

I can't have any way of knowing what DTs may exist as there is only one upstream repository of dts files. There's not really a good solution on this to avoid breaking users, so we'll just have to see if anyone (besides the known users) complains.

Rob

#7 lore raw

PATCH v2 2/3 input: touchscreen: edt-ft5x06: assert reset during suspend

In reply to Daniel Mack

If the device is not configured as wakeup source, it can be put in reset during suspend to save some power.

---
 drivers/input/touchscreen/edt-ft5x06.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)
drivers/input/touchscreen/edt-ft5x06.c +21 -5
index e18a2f215500..145499022e1c 100644
@@ -883,6 +883,20 @@ edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata)
 	}
 }
 
+static void edt_ft5x06_reset(struct edt_ft5x06_ts_data *tsdata, bool reset)
+{
+	if (!tsdata->reset_gpio)
+		return;
+
+	if (reset) {
+		gpiod_set_value_cansleep(tsdata->reset_gpio, 1);
+	} else {
+		usleep_range(5000, 6000);
+		gpiod_set_value_cansleep(tsdata->reset_gpio, 0);
+		msleep(300);
+	}
+}
+
 static int edt_ft5x06_ts_probe(struct i2c_client *client,
 					 const struct i2c_device_id *id)
 {
@@ -934,11 +948,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
 		gpiod_set_value_cansleep(tsdata->wake_gpio, 1);
 	}
 
-	if (tsdata->reset_gpio) {
-		usleep_range(5000, 6000);
-		gpiod_set_value_cansleep(tsdata->reset_gpio, 0);
-		msleep(300);
-	}
+	edt_ft5x06_reset(tsdata, false);
 
 	input = devm_input_allocate_device(&client->dev);
 	if (!input) {
@@ -1034,9 +1044,12 @@ static int edt_ft5x06_ts_remove(struct i2c_client *client)
 static int __maybe_unused edt_ft5x06_ts_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
+	struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client);
 
 	if (device_may_wakeup(dev))
 		enable_irq_wake(client->irq);
+	else
+		edt_ft5x06_reset(tsdata, true);
 
 	return 0;
 }
@@ -1044,9 +1057,12 @@ static int __maybe_unused edt_ft5x06_ts_suspend(struct device *dev)
 static int __maybe_unused edt_ft5x06_ts_resume(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
+	struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client);
 
 	if (device_may_wakeup(dev))
 		disable_irq_wake(client->irq);
+	else
+		edt_ft5x06_reset(tsdata, false);
 
 	return 0;
 }
Signature · 1 line
2.14.3
#8 lore raw

PATCH v2 3/3 ARM: dts: imx28/imx53: enable edt-ft5x06 wakeup source

In reply to Daniel Mack

The touchscreen driver no longer configures the device as wakeup source by default. A "wakeup-source" property is needed.

To avoid regressions, this patch changes the DTS files for the only two users of this driver that didn't have this property yet.

Cc Shawn Guo <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Rob Herring <[email protected]>
---
 arch/arm/boot/dts/imx28-tx28.dts      | 1 +
 arch/arm/boot/dts/imx53-tx53-x03x.dts | 1 +
 2 files changed, 2 insertions(+)
arch/arm/boot/dts/imx28-tx28.dts +1 -0
index 0ebbc83852d0..094a39a67ec8 100644
@@ -328,6 +328,7 @@
 		interrupts = <5 IRQ_TYPE_EDGE_FALLING>;
 		reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>;
 		wake-gpios = <&gpio4 9 GPIO_ACTIVE_HIGH>;
+		wakeup-source;
 	};
 
 	touchscreen: tsc2007 at 48 {
arch/arm/boot/dts/imx53-tx53-x03x.dts +1 -0
index 0ecb43d88522..dbf0d73dc7b9 100644
@@ -220,6 +220,7 @@
 		interrupts = <15 IRQ_TYPE_EDGE_FALLING>;
 		reset-gpios = <&gpio2 22 GPIO_ACTIVE_LOW>;
 		wake-gpios = <&gpio2 21 GPIO_ACTIVE_HIGH>;
+		wakeup-source;
 	};
 
 	touchscreen: tsc2007 at 48 {
Signature · 1 line
2.14.3
Applied
#9 lore raw

PATCH v2 3/3 ARM: dts: imx28/imx53: enable edt-ft5x06 wakeup source

Quoted 11 lines · Daniel Mack

The touchscreen driver no longer configures the device as wakeup source by default. A "wakeup-source" property is needed.

To avoid regressions, this patch changes the DTS files for the only two users of this driver that didn't have this property yet.

Cc Shawn Guo <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Rob Herring <[email protected]>

Applied this one, thanks.

maintainer
#10 lore raw

PATCH v2 3/3 ARM: dts: imx28/imx53: enable edt-ft5x06 wakeup source

Quoted 7 lines · Shawn Guo
Quoted 6 lines · Daniel Mack

The touchscreen driver no longer configures the device as wakeup source by default. A "wakeup-source" property is needed.

To avoid regressions, this patch changes the DTS files for the only two users of this driver that didn't have this property yet.

Quoted 7 lines
Quoted 5 lines
Cc Shawn Guo <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Rob Herring <[email protected]>

Applied this one, thanks.

I think there are few more that need "wakeup-source" added:

arch/arm/boot/dts/am437x-sk-evm.dts
arch/arm/boot/dts/imx6q-var-dt6customboard.dts
arch/arm/boot/dts/imx6qdl-nit6xlite.dtsi
arch/arm/boot/dts/imx6qdl-nitrogen6_max.dtsi
arch/arm/boot/dts/imx6qdl-nitrogen6_som2.dtsi
arch/arm/boot/dts/imx6qdl-nitrogen6x.dtsi

Thanks.

Signature · 1 line
Dmitry
#11 lore raw

PATCH v2 3/3 ARM: dts: imx28/imx53: enable edt-ft5x06 wakeup source

Quoted 16 lines · Dmitry Torokhov
Quoted 7 lines · Shawn Guo
Quoted 6 lines · Daniel Mack

The touchscreen driver no longer configures the device as wakeup source by default. A "wakeup-source" property is needed.

To avoid regressions, this patch changes the DTS files for the only two users of this driver that didn't have this property yet.

Quoted 7 lines
Quoted 5 lines
Cc Shawn Guo <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Rob Herring <[email protected]>

Applied this one, thanks.

Quoted 8 lines

I think there are few more that need "wakeup-source" added:

arch/arm/boot/dts/am437x-sk-evm.dts
arch/arm/boot/dts/imx6q-var-dt6customboard.dts
arch/arm/boot/dts/imx6qdl-nit6xlite.dtsi
arch/arm/boot/dts/imx6qdl-nitrogen6_max.dtsi
arch/arm/boot/dts/imx6qdl-nitrogen6_som2.dtsi
arch/arm/boot/dts/imx6qdl-nitrogen6x.dtsi

Oh, sorry for having missed them. Will send patches.

Thanks,
Daniel