Skip to contentSkip to conversation

pixcir_i2c_ts: Add optional wakeup irq support

PATCH Superseded Vignesh R 3 participants 8 messages Jul 17, 2015 – Jul 20, 2015

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Vignesh R

author
#0 lore raw

cover pixcir_i2c_ts: Add optional wakeup irq support

On am437x-gp-evm, pixcir_i2c_tsc can wake-up system from low power state via pinctrl and IO daisy chain mechanism. This patch series add support for such optional wake up interrupt to be handled via recently introduced generic wake irq handling framework.

Tested on am437x-gp-evm, with some out of tree patches to support suspend/resume on am437x.

Vignesh R (2):
input: touchscreen: pixcir_i2c_ts: Add support for optional wakeup
interrupt
ARM: dts: AM437x-gp-evm: Add wakeup interrupt source for
pixcir_i2c_tsc

 arch/arm/boot/dts/am437x-gp-evm.dts       |  3 +++
 drivers/input/touchscreen/pixcir_i2c_ts.c | 14 ++++++++++++++
 2 files changed, 17 insertions(+)
Signature · 1 line
2.4.5
author
#1 lore raw

PATCH 1/2 input: touchscreen: pixcir_i2c_ts: Add support for optional wakeup interrupt

On am437x-gp-evm, pixcir touchscreen can wake the system from low power state by generating wake-up interrupt via pinctrl and IO daisy chain. Add support for optional wakeup interrupt source by regsitering to automated wake IRQ framework introduced by commit 4990d4fe327b ("PM /
Wakeirq: Add automated device wake IRQ handling").
This is similar in approach to commit 2a0b965cfb6e ("serial: omap: Add support for optional wake-up")

---
 drivers/input/touchscreen/pixcir_i2c_ts.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/input/touchscreen/pixcir_i2c_ts.c +14 -0
index 8f3e243a62bf..f7c602027fbd 100644
@@ -29,6 +29,8 @@
 #include <linux/of.h>
 #include <linux/of_gpio.h>
 #include <linux/of_device.h>
+#include <linux/of_irq.h>
+#include <linux/pm_wakeirq.h>
 
 #define PIXCIR_MAX_SLOTS       5 /* Max fingers supported by driver */
 
@@ -38,6 +40,7 @@ struct pixcir_i2c_ts_data {
 	const struct pixcir_ts_platform_data *pdata;
 	bool running;
 	int max_fingers;	/* Max fingers supported in this instance */
+	int wakeirq;
 };
 
 struct pixcir_touch {
@@ -564,11 +567,22 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
 	i2c_set_clientdata(client, tsdata);
 	device_init_wakeup(&client->dev, 1);
 
+	/* Register wakeirq, if available */
+	tsdata->wakeirq = of_irq_get(dev->of_node, 1);
+	if (tsdata->wakeirq) {
+		error = dev_pm_set_dedicated_wake_irq(dev,
+						      tsdata->wakeirq);
+		if (error)
+			dev_dbg(dev, "unable to get wakeirq %d\n",
+				error);
+	}
+
 	return 0;
 }
 
 static int pixcir_i2c_ts_remove(struct i2c_client *client)
 {
+	dev_pm_clear_wake_irq(&client->dev);
 	device_init_wakeup(&client->dev, 0);
 
 	return 0;
Signature · 1 line
2.4.5
author
#7 lore raw

PATCH 2/2 ARM: dts: am437x-gp-evm: Add wakeup interrupt source for pixcir_i2c_tsc

In reply to Vignesh R

Pixcir_i2c_tsc driver can now wakeup the system from lower power state via pinctrl and IO daisy chain using generic wakeirq framwework. Add optional wakeup irq entry to allow pixcir_i2c_tsc to wake system from low power state.

---
 arch/arm/boot/dts/am437x-gp-evm.dts | 3 +++
 1 file changed, 3 insertions(+)
arch/arm/boot/dts/am437x-gp-evm.dts +3 -0
index 84aa30c3235a..04f7667c604e 100644
@@ -503,6 +503,9 @@
 
 		attb-gpio = <&gpio3 22 GPIO_ACTIVE_HIGH>;
 
+		interrupts-extended = <&gpio3 22 GPIO_ACTIVE_HIGH>,
+				      <&am43xx_pinmux 0x264>;
+
 		touchscreen-size-x = <1024>;
 		touchscreen-size-y = <600>;
 	};
Signature · 1 line
2.4.5
maintainer
#2 lore raw

Re: [PATCH 1/2] input: touchscreen: pixcir_i2c_ts: Add support for optional wakeup interrupt

In reply to Vignesh R

Hi Vignesh,

Quoted 35 lines · Vignesh R

On am437x-gp-evm, pixcir touchscreen can wake the system from low power state by generating wake-up interrupt via pinctrl and IO daisy chain. Add support for optional wakeup interrupt source by regsitering to automated wake IRQ framework introduced by commit 4990d4fe327b ("PM /
Wakeirq: Add automated device wake IRQ handling").
This is similar in approach to commit 2a0b965cfb6e ("serial: omap: Add support for optional wake-up")

---
 drivers/input/touchscreen/pixcir_i2c_ts.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/input/touchscreen/pixcir_i2c_ts.c +3 -0
index 8f3e243a62bf..f7c602027fbd 100644
@@ -29,6 +29,8 @@
 #include <linux/of.h>
 #include <linux/of_gpio.h>
 #include <linux/of_device.h>
+#include <linux/of_irq.h>
+#include <linux/pm_wakeirq.h>
 
 #define PIXCIR_MAX_SLOTS       5 /* Max fingers supported by driver */
 
@@ -38,6 +40,7 @@ struct pixcir_i2c_ts_data {
 	const struct pixcir_ts_platform_data *pdata;
 	bool running;
 	int max_fingers;	/* Max fingers supported in this instance */
+	int wakeirq;
 };
 
 struct pixcir_touch {

drivers/input/touchscreen/pixcir_i2c_ts.c static int pixcir_i2c_ts_probe(struct i2c_client *client, · line 571

Quoted 5 lines
drivers/input/touchscreen/pixcir_i2c_ts.c +2 -0
@@ -564,11 +567,22 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
 	i2c_set_clientdata(client, tsdata);
 	device_init_wakeup(&client->dev, 1);
 
+	/* Register wakeirq, if available */
+	tsdata->wakeirq = of_irq_get(dev->of_node, 1);

Can we put this in platform data and parse in pixcir_parse_dt() please? Also, why not of_irq_get_byname()?

drivers/input/touchscreen/pixcir_i2c_ts.c static int pixcir_i2c_ts_probe(struct i2c_client *client, · line 578

Quoted 7 lines
drivers/input/touchscreen/pixcir_i2c_ts.c +7 -0
+	if (tsdata->wakeirq) {
+		error = dev_pm_set_dedicated_wake_irq(dev,
+						      tsdata->wakeirq);
+		if (error)
+			dev_dbg(dev, "unable to get wakeirq %d\n",
+				error);
+	}

Shouldn't his actually be:

	error = tsdata->wakeirq ?
		dev_pm_set_dedicated_wake_irq(dev, tsdata->wakeirq) :
		dev_pm_set_wake_irq(dev, client->irq);
	if (error) {
		...
	}

and then we can get rid of enable_irq_wake()/disable_irq_wake() in pixcir_i2c_ts_suspend() and pixcir_i2c_ts_resume().

drivers/input/touchscreen/pixcir_i2c_ts.c static int pixcir_i2c_ts_probe(struct i2c_client *client, · line 586

Quoted 8 lines
drivers/input/touchscreen/pixcir_i2c_ts.c +2 -0
+
 	return 0;
 }
 
 static int pixcir_i2c_ts_remove(struct i2c_client *client)
 {
+	dev_pm_clear_wake_irq(&client->dev);
 	device_init_wakeup(&client->dev, 0);

I wonder if driver core should be responsible for clearing wake irq and also for clearing wakeup flag.

Thanks.

Signature · 1 line
Dmitry
author
#3 lore raw

Re: [PATCH 1/2] input: touchscreen: pixcir_i2c_ts: Add support for optional wakeup interrupt

Hi Dmitry,

Quoted 41 lines · Dmitry Torokhov

Hi Vignesh,

Quoted 38 lines · Vignesh R

On am437x-gp-evm, pixcir touchscreen can wake the system from low power state by generating wake-up interrupt via pinctrl and IO daisy chain. Add support for optional wakeup interrupt source by regsitering to automated wake IRQ framework introduced by commit 4990d4fe327b ("PM /
Wakeirq: Add automated device wake IRQ handling").
This is similar in approach to commit 2a0b965cfb6e ("serial: omap: Add support for optional wake-up")

---
 drivers/input/touchscreen/pixcir_i2c_ts.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/input/touchscreen/pixcir_i2c_ts.c +3 -0
index 8f3e243a62bf..f7c602027fbd 100644
@@ -29,6 +29,8 @@
 #include <linux/of.h>
 #include <linux/of_gpio.h>
 #include <linux/of_device.h>
+#include <linux/of_irq.h>
+#include <linux/pm_wakeirq.h>
 
 #define PIXCIR_MAX_SLOTS       5 /* Max fingers supported by driver */
 
@@ -38,6 +40,7 @@ struct pixcir_i2c_ts_data {
 	const struct pixcir_ts_platform_data *pdata;
 	bool running;
 	int max_fingers;	/* Max fingers supported in this instance */
+	int wakeirq;
 };
 
 struct pixcir_touch {
@@ -564,11 +567,22 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
 	i2c_set_clientdata(client, tsdata);
 	device_init_wakeup(&client->dev, 1);
 
Quoted 6 lines

drivers/input/touchscreen/pixcir_i2c_ts.c static int pixcir_i2c_ts_probe(struct i2c_client *client, · line 571

Quoted 2 lines
drivers/input/touchscreen/pixcir_i2c_ts.c +2 -0
+	/* Register wakeirq, if available */
+	tsdata->wakeirq = of_irq_get(dev->of_node, 1);

Can we put this in platform data and parse in pixcir_parse_dt() please? Also, why not of_irq_get_byname()?

Ok.

Quoted 17 lines

drivers/input/touchscreen/pixcir_i2c_ts.c static int pixcir_i2c_ts_probe(struct i2c_client *client, · line 578

Quoted 7 lines
drivers/input/touchscreen/pixcir_i2c_ts.c +7 -0
+	if (tsdata->wakeirq) {
+		error = dev_pm_set_dedicated_wake_irq(dev,
+						      tsdata->wakeirq);
+		if (error)
+			dev_dbg(dev, "unable to get wakeirq %d\n",
+				error);
+	}

Shouldn't his actually be:

	error = tsdata->wakeirq ?
		dev_pm_set_dedicated_wake_irq(dev, tsdata->wakeirq) :
		dev_pm_set_wake_irq(dev, client->irq);
	if (error) {
		...
	}
Quoted 3 lines

and then we can get rid of enable_irq_wake()/disable_irq_wake() in pixcir_i2c_ts_suspend() and pixcir_i2c_ts_resume().

Yes, I will do this in v2.

Quoted 4 lines
Quoted 4 lines
drivers/input/touchscreen/pixcir_i2c_ts.c +1 -0
+
 	return 0;
 }
 
Quoted 8 lines

drivers/input/touchscreen/pixcir_i2c_ts.c static int pixcir_i2c_ts_probe(struct i2c_client *client, · line 586

Quoted 4 lines
drivers/input/touchscreen/pixcir_i2c_ts.c +1 -0
 static int pixcir_i2c_ts_remove(struct i2c_client *client)
 {
+	dev_pm_clear_wake_irq(&client->dev);
 	device_init_wakeup(&client->dev, 0);

I wonder if driver core should be responsible for clearing wake irq and also for clearing wakeup flag.

AFAICU, wakeup flag is deleted when struct device is deleted, hence, device_init_wakeup() call may not be required in .remove(). But, dev_pm_clear_wake_irq() can be moved to driver core.

Regards
Vignesh

#4 lore raw

Re: [PATCH 1/2] input: touchscreen: pixcir_i2c_ts: Add support for optional wakeup interrupt

Quoted 9 lines · Vignesh R
Quoted 4 lines · Dmitry Torokhov

I wonder if driver core should be responsible for clearing wake irq and also for clearing wakeup flag.

AFAICU, wakeup flag is deleted when struct device is deleted, hence, device_init_wakeup() call may not be required in .remove(). But, dev_pm_clear_wake_irq() can be moved to driver core.

Currently the lifecycle of struct wakeup_source is not necessarily the same as the lifecycle struct device. I believe net and usb drivers at least allocate it dynamically.

Regards,

Tony

maintainer
#5 lore raw

Re: [PATCH 1/2] input: touchscreen: pixcir_i2c_ts: Add support for optional wakeup interrupt

Quoted 7 lines · Tony Lindgren
Quoted 6 lines · Vignesh R
Quoted 4 lines · Dmitry Torokhov

I wonder if driver core should be responsible for clearing wake irq and also for clearing wakeup flag.

Quoted 7 lines
Quoted 3 lines

AFAICU, wakeup flag is deleted when struct device is deleted, hence, device_init_wakeup() call may not be required in .remove(). But, dev_pm_clear_wake_irq() can be moved to driver core.

Currently the lifecycle of struct wakeup_source is not necessarily the same as the lifecycle struct device. I believe net and usb drivers at least allocate it dynamically.

I am not sure if I follow. I was wondering if we should clear the wakeup IRQ setting on the driver unbinding. It does not mean that we'd be deleting wakeup_source, just that we'll clear wakeup irq setting from it.

Signature · 1 line
Dmitry
#6 lore raw

Re: [PATCH 1/2] input: touchscreen: pixcir_i2c_ts: Add support for optional wakeup interrupt

Quoted 12 lines · Dmitry Torokhov
Quoted 11 lines · Tony Lindgren
Quoted 9 lines · Vignesh R
Quoted 4 lines · Dmitry Torokhov

I wonder if driver core should be responsible for clearing wake irq and also for clearing wakeup flag.

AFAICU, wakeup flag is deleted when struct device is deleted, hence, device_init_wakeup() call may not be required in .remove(). But, dev_pm_clear_wake_irq() can be moved to driver core.

Quoted 8 lines
Quoted 3 lines

Currently the lifecycle of struct wakeup_source is not necessarily the same as the lifecycle struct device. I believe net and usb drivers at least allocate it dynamically.

I am not sure if I follow. I was wondering if we should clear the wakeup IRQ setting on the driver unbinding. It does not mean that we'd be deleting wakeup_source, just that we'll clear wakeup irq setting from it.

Yes you're right we can do that. I was mostly commenting on why we currently can't automate things further with devm.

Regards,

Tony