All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/3] ti_am335x_tsc: Fix suspend/resume
@ 2018-04-24  6:27 ` Vignesh R
  0 siblings, 0 replies; 13+ messages in thread
From: Vignesh R @ 2018-04-24  6:27 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Vignesh R, Grygorii Strashko, linux-input, linux-kernel,
	linux-omap, Tony Lindgren

This patch series fixes couple of issues wrt suspend/resume with TI AM335x
TSC driver. Disable and clear any pending IRQs before suspend, and
handle case where TSC wakeup would fail, if there were touch events
during suspend.


Grygorii Strashko (2):
  Input: ti_am335x_tsc - Ack pending IRQs at probe and before suspend
  Input: ti_am335x_tsc - Prevent system suspend when TSC is in use

Vignesh R (1):
  Input: ti_am335x_tsc - Mark IRQ as wakeup capable

 drivers/input/touchscreen/ti_am335x_tsc.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

-- 
2.17.0

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

* [PATCH v3 0/3] ti_am335x_tsc: Fix suspend/resume
@ 2018-04-24  6:27 ` Vignesh R
  0 siblings, 0 replies; 13+ messages in thread
From: Vignesh R @ 2018-04-24  6:27 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Vignesh R, Grygorii Strashko, linux-input, linux-kernel,
	linux-omap, Tony Lindgren

This patch series fixes couple of issues wrt suspend/resume with TI AM335x
TSC driver. Disable and clear any pending IRQs before suspend, and
handle case where TSC wakeup would fail, if there were touch events
during suspend.


Grygorii Strashko (2):
  Input: ti_am335x_tsc - Ack pending IRQs at probe and before suspend
  Input: ti_am335x_tsc - Prevent system suspend when TSC is in use

Vignesh R (1):
  Input: ti_am335x_tsc - Mark IRQ as wakeup capable

 drivers/input/touchscreen/ti_am335x_tsc.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

-- 
2.17.0

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

* [PATCH v3 1/3] Input: ti_am335x_tsc - Mark IRQ as wakeup capable
  2018-04-24  6:27 ` Vignesh R
@ 2018-04-24  6:27   ` Vignesh R
  -1 siblings, 0 replies; 13+ messages in thread
From: Vignesh R @ 2018-04-24  6:27 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Vignesh R, Grygorii Strashko, linux-input, linux-kernel,
	linux-omap, Tony Lindgren

On AM335x, ti_am335x_tsc can wake up the system from suspend, mark the
IRQ as wakeup capable, so that device irq is not disabled during system
suspend.

Signed-off-by: Vignesh R <vigneshr@ti.com>
---
v3: Drop unneeded device_may_wakeup() check

 drivers/input/touchscreen/ti_am335x_tsc.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
index f1043ae71dcc..3908c21862c7 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -27,6 +27,7 @@
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/sort.h>
+#include <linux/pm_wakeirq.h>
 
 #include <linux/mfd/ti_am335x_tscadc.h>
 
@@ -432,6 +433,10 @@ static int titsc_probe(struct platform_device *pdev)
 		goto err_free_mem;
 	}
 
+	err = dev_pm_set_wake_irq(tscadc_dev->dev, ts_dev->irq);
+	if (err)
+		dev_err(&pdev->dev, "irq wake enable failed.\n");
+
 	titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_FIFO0THRES);
 	titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_EOS);
 	err = titsc_config_wires(ts_dev);
@@ -462,6 +467,7 @@ static int titsc_probe(struct platform_device *pdev)
 	return 0;
 
 err_free_irq:
+	dev_pm_clear_wake_irq(tscadc_dev->dev);
 	free_irq(ts_dev->irq, ts_dev);
 err_free_mem:
 	input_free_device(input_dev);
@@ -474,6 +480,7 @@ static int titsc_remove(struct platform_device *pdev)
 	struct titsc *ts_dev = platform_get_drvdata(pdev);
 	u32 steps;
 
+	dev_pm_clear_wake_irq(ts_dev->mfd_tscadc->dev);
 	free_irq(ts_dev->irq, ts_dev);
 
 	/* total steps followed by the enable mask */
-- 
2.17.0

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

* [PATCH v3 1/3] Input: ti_am335x_tsc - Mark IRQ as wakeup capable
@ 2018-04-24  6:27   ` Vignesh R
  0 siblings, 0 replies; 13+ messages in thread
From: Vignesh R @ 2018-04-24  6:27 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Vignesh R, Grygorii Strashko, linux-input, linux-kernel,
	linux-omap, Tony Lindgren

On AM335x, ti_am335x_tsc can wake up the system from suspend, mark the
IRQ as wakeup capable, so that device irq is not disabled during system
suspend.

Signed-off-by: Vignesh R <vigneshr@ti.com>
---
v3: Drop unneeded device_may_wakeup() check

 drivers/input/touchscreen/ti_am335x_tsc.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
index f1043ae71dcc..3908c21862c7 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -27,6 +27,7 @@
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/sort.h>
+#include <linux/pm_wakeirq.h>
 
 #include <linux/mfd/ti_am335x_tscadc.h>
 
@@ -432,6 +433,10 @@ static int titsc_probe(struct platform_device *pdev)
 		goto err_free_mem;
 	}
 
+	err = dev_pm_set_wake_irq(tscadc_dev->dev, ts_dev->irq);
+	if (err)
+		dev_err(&pdev->dev, "irq wake enable failed.\n");
+
 	titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_FIFO0THRES);
 	titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_EOS);
 	err = titsc_config_wires(ts_dev);
@@ -462,6 +467,7 @@ static int titsc_probe(struct platform_device *pdev)
 	return 0;
 
 err_free_irq:
+	dev_pm_clear_wake_irq(tscadc_dev->dev);
 	free_irq(ts_dev->irq, ts_dev);
 err_free_mem:
 	input_free_device(input_dev);
@@ -474,6 +480,7 @@ static int titsc_remove(struct platform_device *pdev)
 	struct titsc *ts_dev = platform_get_drvdata(pdev);
 	u32 steps;
 
+	dev_pm_clear_wake_irq(ts_dev->mfd_tscadc->dev);
 	free_irq(ts_dev->irq, ts_dev);
 
 	/* total steps followed by the enable mask */
-- 
2.17.0

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

* [PATCH v3 2/3] Input: ti_am335x_tsc - Ack pending IRQs at probe and before suspend
  2018-04-24  6:27 ` Vignesh R
@ 2018-04-24  6:27   ` Vignesh R
  -1 siblings, 0 replies; 13+ messages in thread
From: Vignesh R @ 2018-04-24  6:27 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Vignesh R, Grygorii Strashko, linux-input, linux-kernel,
	linux-omap, Tony Lindgren

From: Grygorii Strashko <grygorii.strashko@ti.com>

It is seen that just enabling the TSC module triggers a HW_PEN IRQ
without any interaction with touchscreen by user. This results in first
suspend/resume sequence to fail as system immediately wakes up from
suspend as soon as HW_PEN IRQ is enabled in suspend handler due to the
pending IRQ. Therefore clear all IRQs at probe and also in suspend
callback for sanity.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Vignesh R <vigneshr@ti.com>
---

v3: Clear IRQs related to TSC module only

 drivers/input/touchscreen/ti_am335x_tsc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
index 3908c21862c7..a548b0dbe320 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -35,6 +35,8 @@
 #define SEQ_SETTLE		275
 #define MAX_12BIT		((1 << 12) - 1)
 
+#define TSC_IRQENB_MASK		(IRQENB_FIFO0THRES | IRQENB_EOS | IRQENB_HW_PEN)
+
 static const int config_pins[] = {
 	STEPCONFIG_XPP,
 	STEPCONFIG_XNN,
@@ -437,6 +439,7 @@ static int titsc_probe(struct platform_device *pdev)
 	if (err)
 		dev_err(&pdev->dev, "irq wake enable failed.\n");
 
+	titsc_writel(ts_dev, REG_IRQSTATUS, TSC_IRQENB_MASK);
 	titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_FIFO0THRES);
 	titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_EOS);
 	err = titsc_config_wires(ts_dev);
@@ -502,6 +505,7 @@ static int __maybe_unused titsc_suspend(struct device *dev)
 
 	tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev));
 	if (device_may_wakeup(tscadc_dev->dev)) {
+		titsc_writel(ts_dev, REG_IRQSTATUS, TSC_IRQENB_MASK);
 		idle = titsc_readl(ts_dev, REG_IRQENABLE);
 		titsc_writel(ts_dev, REG_IRQENABLE,
 				(idle | IRQENB_HW_PEN));
-- 
2.17.0

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

* [PATCH v3 2/3] Input: ti_am335x_tsc - Ack pending IRQs at probe and before suspend
@ 2018-04-24  6:27   ` Vignesh R
  0 siblings, 0 replies; 13+ messages in thread
From: Vignesh R @ 2018-04-24  6:27 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Vignesh R, Grygorii Strashko, linux-input, linux-kernel,
	linux-omap, Tony Lindgren

From: Grygorii Strashko <grygorii.strashko@ti.com>

It is seen that just enabling the TSC module triggers a HW_PEN IRQ
without any interaction with touchscreen by user. This results in first
suspend/resume sequence to fail as system immediately wakes up from
suspend as soon as HW_PEN IRQ is enabled in suspend handler due to the
pending IRQ. Therefore clear all IRQs at probe and also in suspend
callback for sanity.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Vignesh R <vigneshr@ti.com>
---

v3: Clear IRQs related to TSC module only

 drivers/input/touchscreen/ti_am335x_tsc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
index 3908c21862c7..a548b0dbe320 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -35,6 +35,8 @@
 #define SEQ_SETTLE		275
 #define MAX_12BIT		((1 << 12) - 1)
 
+#define TSC_IRQENB_MASK		(IRQENB_FIFO0THRES | IRQENB_EOS | IRQENB_HW_PEN)
+
 static const int config_pins[] = {
 	STEPCONFIG_XPP,
 	STEPCONFIG_XNN,
@@ -437,6 +439,7 @@ static int titsc_probe(struct platform_device *pdev)
 	if (err)
 		dev_err(&pdev->dev, "irq wake enable failed.\n");
 
+	titsc_writel(ts_dev, REG_IRQSTATUS, TSC_IRQENB_MASK);
 	titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_FIFO0THRES);
 	titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_EOS);
 	err = titsc_config_wires(ts_dev);
@@ -502,6 +505,7 @@ static int __maybe_unused titsc_suspend(struct device *dev)
 
 	tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev));
 	if (device_may_wakeup(tscadc_dev->dev)) {
+		titsc_writel(ts_dev, REG_IRQSTATUS, TSC_IRQENB_MASK);
 		idle = titsc_readl(ts_dev, REG_IRQENABLE);
 		titsc_writel(ts_dev, REG_IRQENABLE,
 				(idle | IRQENB_HW_PEN));
-- 
2.17.0

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

* [PATCH v3 3/3] Input: ti_am335x_tsc - Prevent system suspend when TSC is in use
  2018-04-24  6:27 ` Vignesh R
@ 2018-04-24  6:27   ` Vignesh R
  -1 siblings, 0 replies; 13+ messages in thread
From: Vignesh R @ 2018-04-24  6:27 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Vignesh R, Grygorii Strashko, linux-input, linux-kernel,
	linux-omap, Tony Lindgren

From: Grygorii Strashko <grygorii.strashko@ti.com>

Prevent system suspend while user has finger on touch screen,
because TSC is wakeup source and suspending device while in use will
result in failure to disable the module.
This patch uses pm_stay_awake() and pm_relax() APIs to prevent and
resume system suspend as required.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Vignesh R <vigneshr@ti.com>
---

v3: No change

 drivers/input/touchscreen/ti_am335x_tsc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
index a548b0dbe320..ae6fc9099636 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -277,6 +277,7 @@ static irqreturn_t titsc_irq(int irq, void *dev)
 	if (status & IRQENB_HW_PEN) {
 		ts_dev->pen_down = true;
 		irqclr |= IRQENB_HW_PEN;
+		pm_stay_awake(ts_dev->mfd_tscadc->dev);
 	}
 
 	if (status & IRQENB_PENUP) {
@@ -286,6 +287,7 @@ static irqreturn_t titsc_irq(int irq, void *dev)
 			input_report_key(input_dev, BTN_TOUCH, 0);
 			input_report_abs(input_dev, ABS_PRESSURE, 0);
 			input_sync(input_dev);
+			pm_relax(ts_dev->mfd_tscadc->dev);
 		} else {
 			ts_dev->pen_down = true;
 		}
@@ -524,6 +526,7 @@ static int __maybe_unused titsc_resume(struct device *dev)
 		titsc_writel(ts_dev, REG_IRQWAKEUP,
 				0x00);
 		titsc_writel(ts_dev, REG_IRQCLR, IRQENB_HW_PEN);
+		pm_relax(ts_dev->mfd_tscadc->dev);
 	}
 	titsc_step_config(ts_dev);
 	titsc_writel(ts_dev, REG_FIFO0THR,
-- 
2.17.0

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

* [PATCH v3 3/3] Input: ti_am335x_tsc - Prevent system suspend when TSC is in use
@ 2018-04-24  6:27   ` Vignesh R
  0 siblings, 0 replies; 13+ messages in thread
From: Vignesh R @ 2018-04-24  6:27 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Vignesh R, Grygorii Strashko, linux-input, linux-kernel,
	linux-omap, Tony Lindgren

From: Grygorii Strashko <grygorii.strashko@ti.com>

Prevent system suspend while user has finger on touch screen,
because TSC is wakeup source and suspending device while in use will
result in failure to disable the module.
This patch uses pm_stay_awake() and pm_relax() APIs to prevent and
resume system suspend as required.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Vignesh R <vigneshr@ti.com>
---

v3: No change

 drivers/input/touchscreen/ti_am335x_tsc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
index a548b0dbe320..ae6fc9099636 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -277,6 +277,7 @@ static irqreturn_t titsc_irq(int irq, void *dev)
 	if (status & IRQENB_HW_PEN) {
 		ts_dev->pen_down = true;
 		irqclr |= IRQENB_HW_PEN;
+		pm_stay_awake(ts_dev->mfd_tscadc->dev);
 	}
 
 	if (status & IRQENB_PENUP) {
@@ -286,6 +287,7 @@ static irqreturn_t titsc_irq(int irq, void *dev)
 			input_report_key(input_dev, BTN_TOUCH, 0);
 			input_report_abs(input_dev, ABS_PRESSURE, 0);
 			input_sync(input_dev);
+			pm_relax(ts_dev->mfd_tscadc->dev);
 		} else {
 			ts_dev->pen_down = true;
 		}
@@ -524,6 +526,7 @@ static int __maybe_unused titsc_resume(struct device *dev)
 		titsc_writel(ts_dev, REG_IRQWAKEUP,
 				0x00);
 		titsc_writel(ts_dev, REG_IRQCLR, IRQENB_HW_PEN);
+		pm_relax(ts_dev->mfd_tscadc->dev);
 	}
 	titsc_step_config(ts_dev);
 	titsc_writel(ts_dev, REG_FIFO0THR,
-- 
2.17.0

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

* Re: [PATCH v3 0/3] ti_am335x_tsc: Fix suspend/resume
  2018-04-24  6:27 ` Vignesh R
@ 2018-05-14 15:04   ` Vignesh R
  -1 siblings, 0 replies; 13+ messages in thread
From: Vignesh R @ 2018-05-14 15:04 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Grygorii Strashko, linux-input, linux-kernel, linux-omap, Tony Lindgren



On 24-Apr-18 11:57 AM, Vignesh R wrote:
> This patch series fixes couple of issues wrt suspend/resume with TI AM335x
> TSC driver. Disable and clear any pending IRQs before suspend, and
> handle case where TSC wakeup would fail, if there were touch events
> during suspend.
> 
> 

Gentle ping on this series... Any comments?

> Grygorii Strashko (2):
>   Input: ti_am335x_tsc - Ack pending IRQs at probe and before suspend
>   Input: ti_am335x_tsc - Prevent system suspend when TSC is in use
> 
> Vignesh R (1):
>   Input: ti_am335x_tsc - Mark IRQ as wakeup capable
> 
>  drivers/input/touchscreen/ti_am335x_tsc.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 

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

* Re: [PATCH v3 0/3] ti_am335x_tsc: Fix suspend/resume
@ 2018-05-14 15:04   ` Vignesh R
  0 siblings, 0 replies; 13+ messages in thread
From: Vignesh R @ 2018-05-14 15:04 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Grygorii Strashko, linux-input, linux-kernel, linux-omap, Tony Lindgren



On 24-Apr-18 11:57 AM, Vignesh R wrote:
> This patch series fixes couple of issues wrt suspend/resume with TI AM335x
> TSC driver. Disable and clear any pending IRQs before suspend, and
> handle case where TSC wakeup would fail, if there were touch events
> during suspend.
> 
> 

Gentle ping on this series... Any comments?

> Grygorii Strashko (2):
>   Input: ti_am335x_tsc - Ack pending IRQs at probe and before suspend
>   Input: ti_am335x_tsc - Prevent system suspend when TSC is in use
> 
> Vignesh R (1):
>   Input: ti_am335x_tsc - Mark IRQ as wakeup capable
> 
>  drivers/input/touchscreen/ti_am335x_tsc.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 

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

* Re: [PATCH v3 2/3] Input: ti_am335x_tsc - Ack pending IRQs at probe and before suspend
  2018-04-24  6:27   ` Vignesh R
  (?)
@ 2018-05-30 21:44   ` Dmitry Torokhov
  -1 siblings, 0 replies; 13+ messages in thread
From: Dmitry Torokhov @ 2018-05-30 21:44 UTC (permalink / raw)
  To: Vignesh R
  Cc: Grygorii Strashko, linux-input, linux-kernel, linux-omap, Tony Lindgren

On Tue, Apr 24, 2018 at 11:57:40AM +0530, Vignesh R wrote:
> From: Grygorii Strashko <grygorii.strashko@ti.com>
> 
> It is seen that just enabling the TSC module triggers a HW_PEN IRQ
> without any interaction with touchscreen by user. This results in first
> suspend/resume sequence to fail as system immediately wakes up from
> suspend as soon as HW_PEN IRQ is enabled in suspend handler due to the
> pending IRQ. Therefore clear all IRQs at probe and also in suspend
> callback for sanity.
> 
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
> Signed-off-by: Vignesh R <vigneshr@ti.com>

Applied, thank you.

> ---
> 
> v3: Clear IRQs related to TSC module only
> 
>  drivers/input/touchscreen/ti_am335x_tsc.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
> index 3908c21862c7..a548b0dbe320 100644
> --- a/drivers/input/touchscreen/ti_am335x_tsc.c
> +++ b/drivers/input/touchscreen/ti_am335x_tsc.c
> @@ -35,6 +35,8 @@
>  #define SEQ_SETTLE		275
>  #define MAX_12BIT		((1 << 12) - 1)
>  
> +#define TSC_IRQENB_MASK		(IRQENB_FIFO0THRES | IRQENB_EOS | IRQENB_HW_PEN)
> +
>  static const int config_pins[] = {
>  	STEPCONFIG_XPP,
>  	STEPCONFIG_XNN,
> @@ -437,6 +439,7 @@ static int titsc_probe(struct platform_device *pdev)
>  	if (err)
>  		dev_err(&pdev->dev, "irq wake enable failed.\n");
>  
> +	titsc_writel(ts_dev, REG_IRQSTATUS, TSC_IRQENB_MASK);
>  	titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_FIFO0THRES);
>  	titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_EOS);
>  	err = titsc_config_wires(ts_dev);
> @@ -502,6 +505,7 @@ static int __maybe_unused titsc_suspend(struct device *dev)
>  
>  	tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev));
>  	if (device_may_wakeup(tscadc_dev->dev)) {
> +		titsc_writel(ts_dev, REG_IRQSTATUS, TSC_IRQENB_MASK);
>  		idle = titsc_readl(ts_dev, REG_IRQENABLE);
>  		titsc_writel(ts_dev, REG_IRQENABLE,
>  				(idle | IRQENB_HW_PEN));
> -- 
> 2.17.0
> 

-- 
Dmitry

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

* Re: [PATCH v3 3/3] Input: ti_am335x_tsc - Prevent system suspend when TSC is in use
  2018-04-24  6:27   ` Vignesh R
  (?)
@ 2018-05-30 21:44   ` Dmitry Torokhov
  -1 siblings, 0 replies; 13+ messages in thread
From: Dmitry Torokhov @ 2018-05-30 21:44 UTC (permalink / raw)
  To: Vignesh R
  Cc: Grygorii Strashko, linux-input, linux-kernel, linux-omap, Tony Lindgren

On Tue, Apr 24, 2018 at 11:57:41AM +0530, Vignesh R wrote:
> From: Grygorii Strashko <grygorii.strashko@ti.com>
> 
> Prevent system suspend while user has finger on touch screen,
> because TSC is wakeup source and suspending device while in use will
> result in failure to disable the module.
> This patch uses pm_stay_awake() and pm_relax() APIs to prevent and
> resume system suspend as required.
> 
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
> Signed-off-by: Vignesh R <vigneshr@ti.com>

Applied, thank you.

> ---
> 
> v3: No change
> 
>  drivers/input/touchscreen/ti_am335x_tsc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
> index a548b0dbe320..ae6fc9099636 100644
> --- a/drivers/input/touchscreen/ti_am335x_tsc.c
> +++ b/drivers/input/touchscreen/ti_am335x_tsc.c
> @@ -277,6 +277,7 @@ static irqreturn_t titsc_irq(int irq, void *dev)
>  	if (status & IRQENB_HW_PEN) {
>  		ts_dev->pen_down = true;
>  		irqclr |= IRQENB_HW_PEN;
> +		pm_stay_awake(ts_dev->mfd_tscadc->dev);
>  	}
>  
>  	if (status & IRQENB_PENUP) {
> @@ -286,6 +287,7 @@ static irqreturn_t titsc_irq(int irq, void *dev)
>  			input_report_key(input_dev, BTN_TOUCH, 0);
>  			input_report_abs(input_dev, ABS_PRESSURE, 0);
>  			input_sync(input_dev);
> +			pm_relax(ts_dev->mfd_tscadc->dev);
>  		} else {
>  			ts_dev->pen_down = true;
>  		}
> @@ -524,6 +526,7 @@ static int __maybe_unused titsc_resume(struct device *dev)
>  		titsc_writel(ts_dev, REG_IRQWAKEUP,
>  				0x00);
>  		titsc_writel(ts_dev, REG_IRQCLR, IRQENB_HW_PEN);
> +		pm_relax(ts_dev->mfd_tscadc->dev);
>  	}
>  	titsc_step_config(ts_dev);
>  	titsc_writel(ts_dev, REG_FIFO0THR,
> -- 
> 2.17.0
> 

-- 
Dmitry

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

* Re: [PATCH v3 1/3] Input: ti_am335x_tsc - Mark IRQ as wakeup capable
  2018-04-24  6:27   ` Vignesh R
  (?)
@ 2018-05-30 21:47   ` Dmitry Torokhov
  -1 siblings, 0 replies; 13+ messages in thread
From: Dmitry Torokhov @ 2018-05-30 21:47 UTC (permalink / raw)
  To: Vignesh R
  Cc: Grygorii Strashko, linux-input, linux-kernel, linux-omap, Tony Lindgren

Hi Vignesh,

On Tue, Apr 24, 2018 at 11:57:39AM +0530, Vignesh R wrote:
> On AM335x, ti_am335x_tsc can wake up the system from suspend, mark the
> IRQ as wakeup capable, so that device irq is not disabled during system
> suspend.
> 
> Signed-off-by: Vignesh R <vigneshr@ti.com>
> ---
> v3: Drop unneeded device_may_wakeup() check
> 
>  drivers/input/touchscreen/ti_am335x_tsc.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
> index f1043ae71dcc..3908c21862c7 100644
> --- a/drivers/input/touchscreen/ti_am335x_tsc.c
> +++ b/drivers/input/touchscreen/ti_am335x_tsc.c
> @@ -27,6 +27,7 @@
>  #include <linux/of.h>
>  #include <linux/of_device.h>
>  #include <linux/sort.h>
> +#include <linux/pm_wakeirq.h>
>  
>  #include <linux/mfd/ti_am335x_tscadc.h>
>  
> @@ -432,6 +433,10 @@ static int titsc_probe(struct platform_device *pdev)
>  		goto err_free_mem;
>  	}
>  
> +	err = dev_pm_set_wake_irq(tscadc_dev->dev, ts_dev->irq);
> +	if (err)
> +		dev_err(&pdev->dev, "irq wake enable failed.\n");
> +

Looking at this driver some more: why do we have the parent MFD device
as wakeup source? It seems we have 2 independent interrupt lines, one in
IIO and one in input and we could actually have the touchscreen itself
to be one of the wakeup devices? I.e. i'd expect

	err = dev_pm_set_wake_irq(&pdev->dev, ts_dev->irq);

here and we should be checking the touchscreen pdev in suspend/resume
when checking whether to program the controller for wakeups.


>  	titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_FIFO0THRES);
>  	titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_EOS);
>  	err = titsc_config_wires(ts_dev);
> @@ -462,6 +467,7 @@ static int titsc_probe(struct platform_device *pdev)
>  	return 0;
>  
>  err_free_irq:
> +	dev_pm_clear_wake_irq(tscadc_dev->dev);
>  	free_irq(ts_dev->irq, ts_dev);
>  err_free_mem:
>  	input_free_device(input_dev);
> @@ -474,6 +480,7 @@ static int titsc_remove(struct platform_device *pdev)
>  	struct titsc *ts_dev = platform_get_drvdata(pdev);
>  	u32 steps;
>  
> +	dev_pm_clear_wake_irq(ts_dev->mfd_tscadc->dev);
>  	free_irq(ts_dev->irq, ts_dev);
>  
>  	/* total steps followed by the enable mask */
> -- 
> 2.17.0
> 

Thanks.

-- 
Dmitry

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

end of thread, other threads:[~2018-05-30 21:47 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-24  6:27 [PATCH v3 0/3] ti_am335x_tsc: Fix suspend/resume Vignesh R
2018-04-24  6:27 ` Vignesh R
2018-04-24  6:27 ` [PATCH v3 1/3] Input: ti_am335x_tsc - Mark IRQ as wakeup capable Vignesh R
2018-04-24  6:27   ` Vignesh R
2018-05-30 21:47   ` Dmitry Torokhov
2018-04-24  6:27 ` [PATCH v3 2/3] Input: ti_am335x_tsc - Ack pending IRQs at probe and before suspend Vignesh R
2018-04-24  6:27   ` Vignesh R
2018-05-30 21:44   ` Dmitry Torokhov
2018-04-24  6:27 ` [PATCH v3 3/3] Input: ti_am335x_tsc - Prevent system suspend when TSC is in use Vignesh R
2018-04-24  6:27   ` Vignesh R
2018-05-30 21:44   ` Dmitry Torokhov
2018-05-14 15:04 ` [PATCH v3 0/3] ti_am335x_tsc: Fix suspend/resume Vignesh R
2018-05-14 15:04   ` Vignesh R

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.