Skip to contentSkip to conversation

ti_am335x_tsc: Enable wakeup capability

PATCH Applied Vignesh R 4 participants 27 messages Jun 30, 2018 – Oct 9, 2018

Subsystems (4)
lore
Share & tools
lore
author
#1 lore raw

PATCH 1/5 mfd: ti_am335x_tscadc: Don't mark TSCADC MFD as wakeup capable

In reply to Vignesh R

Currently tscadc MFD is marked as wakeup capable which incorrect because, its actually touch event by child TSC device that wakes up the system. Therefore, remove device_init_wakeup() call that marks TSCADC device as wakeup capable in favor of moving to mark TSC input device as wakeup capable later.

---
 drivers/mfd/ti_am335x_tscadc.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mfd/ti_am335x_tscadc.c +0 -1
index 47012c0899cd..858c1a071a81 100644
@@ -270,7 +270,6 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	if (err < 0)
 		goto err_disable_clk;
 
-	device_init_wakeup(&pdev->dev, true);
 	platform_set_drvdata(pdev, tscadc);
 	return 0;
 
Signature · 1 line
2.18.0

Vignesh R

author
#0 lore raw

cover ti_am335x_tsc: Enable wakeup capability

On AM335x, resistive TSC can wakeup the system from low power state. Currently, parent MFD device is marked as wakeup source, which is inaccurate as its the touch event generated by TSC thats the wakeup source. This series moves all wakeup related calls to operate on TSC device instead of MFD. It also marks TSC IRQ as wakeup capable, so that its not disabled during system suspend.

This series is based on Dmitry's comments here:
https://lkml.org/lkml/2018/4/24/65

There are many new patches in this series, hence did not mark this as v4.

Vignesh R (5):
mfd: ti_am335x_tscadc: Don't mark TSCADC MFD as wakeup capable
Input: ti_am335x_tsc: Mark TSC device as wakeup source
mfd: ti_am335x_tscadc: Keep ADC interface on if child is wakeup
capable
iio: adc: ti_am335x_adc: Disable ADC during suspend unconditionally
Input: ti_am335x_tsc: Mark IRQ as wakeup capable

 drivers/iio/adc/ti_am335x_adc.c           | 12 ++++--------
 drivers/input/touchscreen/ti_am335x_tsc.c | 22 +++++++++++++++++-----
 drivers/mfd/ti_am335x_tscadc.c            | 14 +++++++++++++-
 3 files changed, 34 insertions(+), 14 deletions(-)
Signature · 1 line
2.18.0
author
#7 lore raw

PATCH 3/5 mfd: ti_am335x_tscadc: Keep ADC interface on if child is wakeup capable

If a child device like touchscreen is wakeup capable, then keep ADC interface on, so that a touching resistive screen will generate wakeup event to the system.

---
 drivers/mfd/ti_am335x_tscadc.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/mfd/ti_am335x_tscadc.c +13 -0
index 858c1a071a81..c21ed54d1662 100644
@@ -294,11 +294,24 @@ static int ti_tscadc_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static int __maybe_unused ti_tscadc_can_wakeup(struct device *dev, void *data)
+{
+	return device_may_wakeup(dev);
+}
+
 static int __maybe_unused tscadc_suspend(struct device *dev)
 {
 	struct ti_tscadc_dev	*tscadc = dev_get_drvdata(dev);
 
 	regmap_write(tscadc->regmap, REG_SE, 0x00);
+	if (device_for_each_child(dev, NULL, ti_tscadc_can_wakeup)) {
+		u32 ctrl;
+
+		regmap_read(tscadc->regmap, REG_CTRL, &ctrl);
+		ctrl &= ~(CNTRLREG_POWERDOWN);
+		ctrl |= CNTRLREG_TSCSSENB;
+		regmap_write(tscadc->regmap, REG_CTRL, ctrl);
+	}
 	pm_runtime_put_sync(dev);
 
 	return 0;
Signature · 1 line
2.18.0
author
#4 lore raw

PATCH 2/5 Input: ti_am335x_tsc: Mark TSC device as wakeup source

In reply to Vignesh R

Instead of TSCADC MFD device, mark TSC as wakeup source and change all wakeup related PM calls to operate on TSC device.

---
 drivers/input/touchscreen/ti_am335x_tsc.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/input/touchscreen/ti_am335x_tsc.c +11 -5
index b86c1e5fbc11..a4f25a915ffc 100644
@@ -46,6 +46,7 @@ static const int config_pins[] = {
 struct titsc {
 	struct input_dev	*input;
 	struct ti_tscadc_dev	*mfd_tscadc;
+	struct device		*dev;
 	unsigned int		irq;
 	unsigned int		wires;
 	unsigned int		x_plate_resistance;
@@ -276,7 +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);
+		pm_stay_awake(ts_dev->dev);
 	}
 
 	if (status & IRQENB_PENUP) {
@@ -286,7 +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);
+			pm_relax(ts_dev->dev);
 		} else {
 			ts_dev->pen_down = true;
 		}
@@ -422,6 +423,7 @@ static int titsc_probe(struct platform_device *pdev)
 	ts_dev->mfd_tscadc = tscadc_dev;
 	ts_dev->input = input_dev;
 	ts_dev->irq = tscadc_dev->irq;
+	ts_dev->dev = &pdev->dev;
 
 	err = titsc_parse_dt(pdev, ts_dev);
 	if (err) {
@@ -436,6 +438,8 @@ static int titsc_probe(struct platform_device *pdev)
 		goto err_free_mem;
 	}
 
+	device_init_wakeup(&pdev->dev, true);
+
 	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);
@@ -467,6 +471,7 @@ static int titsc_probe(struct platform_device *pdev)
 	return 0;
 
 err_free_irq:
+	device_init_wakeup(&pdev->dev, false);
 	free_irq(ts_dev->irq, ts_dev);
 err_free_mem:
 	input_free_device(input_dev);
@@ -479,6 +484,7 @@ static int titsc_remove(struct platform_device *pdev)
 	struct titsc *ts_dev = platform_get_drvdata(pdev);
 	u32 steps;
 
+	device_init_wakeup(&pdev->dev, false);
 	free_irq(ts_dev->irq, ts_dev);
 
 	/* total steps followed by the enable mask */
@@ -499,7 +505,7 @@ static int __maybe_unused titsc_suspend(struct device *dev)
 	unsigned int idle;
 
 	tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev));
-	if (device_may_wakeup(tscadc_dev->dev)) {
+	if (device_may_wakeup(dev)) {
 		titsc_writel(ts_dev, REG_IRQSTATUS, TSC_IRQENB_MASK);
 		idle = titsc_readl(ts_dev, REG_IRQENABLE);
 		titsc_writel(ts_dev, REG_IRQENABLE,
@@ -515,11 +521,11 @@ static int __maybe_unused titsc_resume(struct device *dev)
 	struct ti_tscadc_dev *tscadc_dev;
 
 	tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev));
-	if (device_may_wakeup(tscadc_dev->dev)) {
+	if (device_may_wakeup(dev)) {
 		titsc_writel(ts_dev, REG_IRQWAKEUP,
 				0x00);
 		titsc_writel(ts_dev, REG_IRQCLR, IRQENB_HW_PEN);
-		pm_relax(ts_dev->mfd_tscadc->dev);
+		pm_relax(dev);
 	}
 	titsc_step_config(ts_dev);
 	titsc_writel(ts_dev, REG_FIFO0THR,
Signature · 1 line
2.18.0
author
#14 lore raw

PATCH 5/5 Input: ti_am335x_tsc: Mark IRQ as wakeup capable

In reply to Vignesh R

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.

---
 drivers/input/touchscreen/ti_am335x_tsc.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/input/touchscreen/ti_am335x_tsc.c +6 -0
index a4f25a915ffc..9e8684ab48f4 100644
@@ -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>
 
@@ -439,6 +440,9 @@ static int titsc_probe(struct platform_device *pdev)
 	}
 
 	device_init_wakeup(&pdev->dev, true);
+	err = dev_pm_set_wake_irq(&pdev->dev, ts_dev->irq);
+	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);
@@ -471,6 +475,7 @@ static int titsc_probe(struct platform_device *pdev)
 	return 0;
 
 err_free_irq:
+	dev_pm_clear_wake_irq(&pdev->dev);
 	device_init_wakeup(&pdev->dev, false);
 	free_irq(ts_dev->irq, ts_dev);
 err_free_mem:
@@ -484,6 +489,7 @@ static int titsc_remove(struct platform_device *pdev)
 	struct titsc *ts_dev = platform_get_drvdata(pdev);
 	u32 steps;
 
+	dev_pm_clear_wake_irq(&pdev->dev);
 	device_init_wakeup(&pdev->dev, false);
 	free_irq(ts_dev->irq, ts_dev);
 
Signature · 1 line
2.18.0
author
#10 lore raw

PATCH 4/5 iio: adc: ti_am335x_adc: Disable ADC during suspend unconditionally

In reply to Vignesh R

Parent MFD device takes care of enabling ADC interface whenever touchscreen is marked wakeup capable. Therefore, unconditionally disable ADC interface during system suspend to save power in case of system with just ADC and no TSC.

---
 drivers/iio/adc/ti_am335x_adc.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/iio/adc/ti_am335x_adc.c +4 -8
index 80df5a377d30..cafb1dcadc48 100644
@@ -693,16 +693,12 @@ static int __maybe_unused tiadc_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct tiadc_device *adc_dev = iio_priv(indio_dev);
-	struct ti_tscadc_dev *tscadc_dev;
 	unsigned int idle;
 
-	tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev));
-	if (!device_may_wakeup(tscadc_dev->dev)) {
-		idle = tiadc_readl(adc_dev, REG_CTRL);
-		idle &= ~(CNTRLREG_TSCSSENB);
-		tiadc_writel(adc_dev, REG_CTRL, (idle |
-				CNTRLREG_POWERDOWN));
-	}
+	idle = tiadc_readl(adc_dev, REG_CTRL);
+	idle &= ~(CNTRLREG_TSCSSENB);
+	tiadc_writel(adc_dev, REG_CTRL, (idle |
+			CNTRLREG_POWERDOWN));
 
 	return 0;
 }
Signature · 1 line
2.18.0
maintainer Acked-by on v1 4/5
#11 lore raw

Re: [PATCH 4/5] iio: adc: ti_am335x_adc: Disable ADC during suspend unconditionally

Quoted 6 lines · On Sat, 30 Jun 2018 16:03:17 +0530 Vignesh R <[email protected]> wrote:

Parent MFD device takes care of enabling ADC interface whenever touchscreen is marked wakeup capable. Therefore, unconditionally disable ADC interface during system suspend to save power in case of system with just ADC and no TSC.

This sounds like a sensible change to me. Is it applicable without the
rest of the series? If so I'll take it through IIO. If the answer is that it needs to go with the rest then

Thanks,

Jonathan

Quoted 29 lines
---
 drivers/iio/adc/ti_am335x_adc.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/iio/adc/ti_am335x_adc.c +4 -8
index 80df5a377d30..cafb1dcadc48 100644
@@ -693,16 +693,12 @@ static int __maybe_unused tiadc_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct tiadc_device *adc_dev = iio_priv(indio_dev);
-	struct ti_tscadc_dev *tscadc_dev;
 	unsigned int idle;
 
-	tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev));
-	if (!device_may_wakeup(tscadc_dev->dev)) {
-		idle = tiadc_readl(adc_dev, REG_CTRL);
-		idle &= ~(CNTRLREG_TSCSSENB);
-		tiadc_writel(adc_dev, REG_CTRL, (idle |
-				CNTRLREG_POWERDOWN));
-	}
+	idle = tiadc_readl(adc_dev, REG_CTRL);
+	idle &= ~(CNTRLREG_TSCSSENB);
+	tiadc_writel(adc_dev, REG_CTRL, (idle |
+			CNTRLREG_POWERDOWN));
 
 	return 0;
 }
#2 lore raw

Re: [PATCH 1/5] mfd: ti_am335x_tscadc: Don't mark TSCADC MFD as wakeup capable

In reply to Vignesh R
Quoted 10 lines · Vignesh R

Currently tscadc MFD is marked as wakeup capable which incorrect because, its actually touch event by child TSC device that wakes up the system. Therefore, remove device_init_wakeup() call that marks TSCADC device as wakeup capable in favor of moving to mark TSC input device as wakeup capable later.

---
 drivers/mfd/ti_am335x_tscadc.c | 1 -
 1 file changed, 1 deletion(-)

For my own reference:

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#8 lore raw

Re: [PATCH 3/5] mfd: ti_am335x_tscadc: Keep ADC interface on if child is wakeup capable

In reply to Vignesh R
Quoted 8 lines · Vignesh R

If a child device like touchscreen is wakeup capable, then keep ADC interface on, so that a touching resistive screen will generate wakeup event to the system.

---
 drivers/mfd/ti_am335x_tscadc.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

For my own reference:

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
author
#12 lore raw

Re: [PATCH 4/5] iio: adc: ti_am335x_adc: Disable ADC during suspend unconditionally

In reply to Jonathan Cameron
Quoted 8 lines · Jonathan Cameron
Quoted 5 lines · On Sat, 30 Jun 2018 16:03:17 +0530 Vignesh R <[email protected]> wrote:

Parent MFD device takes care of enabling ADC interface whenever touchscreen is marked wakeup capable. Therefore, unconditionally disable ADC interface during system suspend to save power in case of system with just ADC and no TSC.

Quoted 6 lines
Quoted 1 line

This sounds like a sensible change to me. Is it applicable without the
rest of the series? If so I'll take it through IIO. If the answer is that it needs to go with the rest then

This patch as such does not have any compile time dependencies on other patches, but I would like Dmitry's opinion on the series before being merged.

Quoted 2 lines

Thanks!

Regards
Vignesh

Quoted 33 lines

Thanks,

Jonathan

Quoted 29 lines
---
 drivers/iio/adc/ti_am335x_adc.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/iio/adc/ti_am335x_adc.c +4 -8
index 80df5a377d30..cafb1dcadc48 100644
@@ -693,16 +693,12 @@ static int __maybe_unused tiadc_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct tiadc_device *adc_dev = iio_priv(indio_dev);
-	struct ti_tscadc_dev *tscadc_dev;
 	unsigned int idle;
 
-	tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev));
-	if (!device_may_wakeup(tscadc_dev->dev)) {
-		idle = tiadc_readl(adc_dev, REG_CTRL);
-		idle &= ~(CNTRLREG_TSCSSENB);
-		tiadc_writel(adc_dev, REG_CTRL, (idle |
-				CNTRLREG_POWERDOWN));
-	}
+	idle = tiadc_readl(adc_dev, REG_CTRL);
+	idle &= ~(CNTRLREG_TSCSSENB);
+	tiadc_writel(adc_dev, REG_CTRL, (idle |
+			CNTRLREG_POWERDOWN));
 
 	return 0;
 }
Signature · 2 lines
Regards
Vignesh
author
#17 lore raw
In reply to Vignesh R

Hi Dmitry,

Quoted 20 lines · Vignesh R

On AM335x, resistive TSC can wakeup the system from low power state. Currently, parent MFD device is marked as wakeup source, which is inaccurate as its the touch event generated by TSC thats the wakeup source. This series moves all wakeup related calls to operate on TSC device instead of MFD. It also marks TSC IRQ as wakeup capable, so that its not disabled during system suspend.

This series is based on Dmitry's comments here:
https://lkml.org/lkml/2018/4/24/65

There are many new patches in this series, hence did not mark this as v4.

Vignesh R (5):
mfd: ti_am335x_tscadc: Don't mark TSCADC MFD as wakeup capable
Input: ti_am335x_tsc: Mark TSC device as wakeup source
mfd: ti_am335x_tscadc: Keep ADC interface on if child is wakeup
capable
iio: adc: ti_am335x_adc: Disable ADC during suspend unconditionally
Input: ti_am335x_tsc: Mark IRQ as wakeup capable

Quoted 5 lines
 drivers/iio/adc/ti_am335x_adc.c           | 12 ++++--------
 drivers/input/touchscreen/ti_am335x_tsc.c | 22 +++++++++++++++++-----
 drivers/mfd/ti_am335x_tscadc.c            | 14 +++++++++++++-
 3 files changed, 34 insertions(+), 14 deletions(-)

Gentle ping... Could you review/pick this series? MFD amd IIO bits are already ACKed

Signature · 2 lines
Regards
Vignesh
#18 lore raw
Quoted 23 lines · Vignesh R

Hi Dmitry,

Quoted 20 lines · Vignesh R

On AM335x, resistive TSC can wakeup the system from low power state. Currently, parent MFD device is marked as wakeup source, which is inaccurate as its the touch event generated by TSC thats the wakeup source. This series moves all wakeup related calls to operate on TSC device instead of MFD. It also marks TSC IRQ as wakeup capable, so that its not disabled during system suspend.

This series is based on Dmitry's comments here:
https://lkml.org/lkml/2018/4/24/65

There are many new patches in this series, hence did not mark this as v4.

Vignesh R (5):
mfd: ti_am335x_tscadc: Don't mark TSCADC MFD as wakeup capable
Input: ti_am335x_tsc: Mark TSC device as wakeup source
mfd: ti_am335x_tscadc: Keep ADC interface on if child is wakeup
capable
iio: adc: ti_am335x_adc: Disable ADC during suspend unconditionally
Input: ti_am335x_tsc: Mark IRQ as wakeup capable

Quoted 8 lines
Quoted 5 lines
 drivers/iio/adc/ti_am335x_adc.c           | 12 ++++--------
 drivers/input/touchscreen/ti_am335x_tsc.c | 22 +++++++++++++++++-----
 drivers/mfd/ti_am335x_tscadc.c            | 14 +++++++++++++-
 3 files changed, 34 insertions(+), 14 deletions(-)

Gentle ping... Could you review/pick this series? MFD amd IIO bits are already ACKed

MFD patches are reviewed "for my own reference" meaning that we haven't yet agreed on a merge plan yet.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
maintainer Acked-by on v1 5/5
#15 lore raw

Re: [PATCH 5/5] Input: ti_am335x_tsc: Mark IRQ as wakeup capable

In reply to Vignesh R
Quoted 5 lines · Vignesh R

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.

Quoted 45 lines
---
 drivers/input/touchscreen/ti_am335x_tsc.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/input/touchscreen/ti_am335x_tsc.c +6 -0
index a4f25a915ffc..9e8684ab48f4 100644
@@ -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>
 
@@ -439,6 +440,9 @@ static int titsc_probe(struct platform_device *pdev)
 	}
 
 	device_init_wakeup(&pdev->dev, true);
+	err = dev_pm_set_wake_irq(&pdev->dev, ts_dev->irq);
+	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);
@@ -471,6 +475,7 @@ static int titsc_probe(struct platform_device *pdev)
 	return 0;
 
 err_free_irq:
+	dev_pm_clear_wake_irq(&pdev->dev);
 	device_init_wakeup(&pdev->dev, false);
 	free_irq(ts_dev->irq, ts_dev);
 err_free_mem:
@@ -484,6 +489,7 @@ static int titsc_remove(struct platform_device *pdev)
 	struct titsc *ts_dev = platform_get_drvdata(pdev);
 	u32 steps;
 
+	dev_pm_clear_wake_irq(&pdev->dev);
 	device_init_wakeup(&pdev->dev, false);
 	free_irq(ts_dev->irq, ts_dev);
 
Signature · 1 line
2.18.0
Signature · 1 line
Dmitry
maintainer Acked-by on v1 2/5
#5 lore raw

Re: [PATCH 2/5] Input: ti_am335x_tsc: Mark TSC device as wakeup source

In reply to Vignesh R
Quoted 4 lines · Vignesh R

Instead of TSCADC MFD device, mark TSC as wakeup source and change all wakeup related PM calls to operate on TSC device.

Quoted 93 lines
---
 drivers/input/touchscreen/ti_am335x_tsc.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/input/touchscreen/ti_am335x_tsc.c +11 -5
index b86c1e5fbc11..a4f25a915ffc 100644
@@ -46,6 +46,7 @@ static const int config_pins[] = {
 struct titsc {
 	struct input_dev	*input;
 	struct ti_tscadc_dev	*mfd_tscadc;
+	struct device		*dev;
 	unsigned int		irq;
 	unsigned int		wires;
 	unsigned int		x_plate_resistance;
@@ -276,7 +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);
+		pm_stay_awake(ts_dev->dev);
 	}
 
 	if (status & IRQENB_PENUP) {
@@ -286,7 +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);
+			pm_relax(ts_dev->dev);
 		} else {
 			ts_dev->pen_down = true;
 		}
@@ -422,6 +423,7 @@ static int titsc_probe(struct platform_device *pdev)
 	ts_dev->mfd_tscadc = tscadc_dev;
 	ts_dev->input = input_dev;
 	ts_dev->irq = tscadc_dev->irq;
+	ts_dev->dev = &pdev->dev;
 
 	err = titsc_parse_dt(pdev, ts_dev);
 	if (err) {
@@ -436,6 +438,8 @@ static int titsc_probe(struct platform_device *pdev)
 		goto err_free_mem;
 	}
 
+	device_init_wakeup(&pdev->dev, true);
+
 	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);
@@ -467,6 +471,7 @@ static int titsc_probe(struct platform_device *pdev)
 	return 0;
 
 err_free_irq:
+	device_init_wakeup(&pdev->dev, false);
 	free_irq(ts_dev->irq, ts_dev);
 err_free_mem:
 	input_free_device(input_dev);
@@ -479,6 +484,7 @@ static int titsc_remove(struct platform_device *pdev)
 	struct titsc *ts_dev = platform_get_drvdata(pdev);
 	u32 steps;
 
+	device_init_wakeup(&pdev->dev, false);
 	free_irq(ts_dev->irq, ts_dev);
 
 	/* total steps followed by the enable mask */
@@ -499,7 +505,7 @@ static int __maybe_unused titsc_suspend(struct device *dev)
 	unsigned int idle;
 
 	tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev));
-	if (device_may_wakeup(tscadc_dev->dev)) {
+	if (device_may_wakeup(dev)) {
 		titsc_writel(ts_dev, REG_IRQSTATUS, TSC_IRQENB_MASK);
 		idle = titsc_readl(ts_dev, REG_IRQENABLE);
 		titsc_writel(ts_dev, REG_IRQENABLE,
@@ -515,11 +521,11 @@ static int __maybe_unused titsc_resume(struct device *dev)
 	struct ti_tscadc_dev *tscadc_dev;
 
 	tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev));
-	if (device_may_wakeup(tscadc_dev->dev)) {
+	if (device_may_wakeup(dev)) {
 		titsc_writel(ts_dev, REG_IRQWAKEUP,
 				0x00);
 		titsc_writel(ts_dev, REG_IRQCLR, IRQENB_HW_PEN);
-		pm_relax(ts_dev->mfd_tscadc->dev);
+		pm_relax(dev);
 	}
 	titsc_step_config(ts_dev);
 	titsc_writel(ts_dev, REG_FIFO0THR,
Signature · 1 line
2.18.0
Signature · 1 line
Dmitry
maintainer
#19 lore raw
In reply to Lee Jones
Quoted 31 lines · Lee Jones
Quoted 29 lines · Vignesh R

Hi Dmitry,

Quoted 25 lines · Vignesh R

On AM335x, resistive TSC can wakeup the system from low power state. Currently, parent MFD device is marked as wakeup source, which is inaccurate as its the touch event generated by TSC thats the wakeup source. This series moves all wakeup related calls to operate on TSC device instead of MFD. It also marks TSC IRQ as wakeup capable, so that its not disabled during system suspend.

This series is based on Dmitry's comments here:
https://lkml.org/lkml/2018/4/24/65

There are many new patches in this series, hence did not mark this as v4.

Vignesh R (5):
mfd: ti_am335x_tscadc: Don't mark TSCADC MFD as wakeup capable
Input: ti_am335x_tsc: Mark TSC device as wakeup source
mfd: ti_am335x_tscadc: Keep ADC interface on if child is wakeup
capable
iio: adc: ti_am335x_adc: Disable ADC during suspend unconditionally
Input: ti_am335x_tsc: Mark IRQ as wakeup capable

 drivers/iio/adc/ti_am335x_adc.c           | 12 ++++--------
 drivers/input/touchscreen/ti_am335x_tsc.c | 22 +++++++++++++++++-----
 drivers/mfd/ti_am335x_tscadc.c            | 14 +++++++++++++-
 3 files changed, 34 insertions(+), 14 deletions(-)
Quoted 5 lines
Quoted 2 lines

Gentle ping... Could you review/pick this series? MFD amd IIO bits are already ACKed

MFD patches are reviewed "for my own reference" meaning that we haven't yet agreed on a merge plan yet.

I think this series makes sense to be pushed through a single tree as opposed to being spread between 3, even if it could technically be possible. It looks like Jonathan is fine with going it through either his or some other tree, I am fine with it going through MFD. I just Acked the 2 input-related patches.

Thanks.

Signature · 1 line
Dmitry
maintainer
#20 lore raw
Quoted 35 lines · On Wed, 18 Jul 2018 17:09:02 +0000 Dmitry Torokhov <[email protected]>…
Quoted 34 lines · Lee Jones
Quoted 31 lines · Vignesh R

Hi Dmitry,

Quoted 20 lines · Vignesh R

On AM335x, resistive TSC can wakeup the system from low power state. Currently, parent MFD device is marked as wakeup source, which is inaccurate as its the touch event generated by TSC thats the wakeup source. This series moves all wakeup related calls to operate on TSC device instead of MFD. It also marks TSC IRQ as wakeup capable, so that its not disabled during system suspend.

This series is based on Dmitry's comments here:
https://lkml.org/lkml/2018/4/24/65

There are many new patches in this series, hence did not mark this as v4.

Vignesh R (5):
mfd: ti_am335x_tscadc: Don't mark TSCADC MFD as wakeup capable
Input: ti_am335x_tsc: Mark TSC device as wakeup source
mfd: ti_am335x_tscadc: Keep ADC interface on if child is wakeup
capable
iio: adc: ti_am335x_adc: Disable ADC during suspend unconditionally
Input: ti_am335x_tsc: Mark IRQ as wakeup capable

Quoted 5 lines
 drivers/iio/adc/ti_am335x_adc.c           | 12 ++++--------
 drivers/input/touchscreen/ti_am335x_tsc.c | 22 +++++++++++++++++-----
 drivers/mfd/ti_am335x_tscadc.c            | 14 +++++++++++++-
 3 files changed, 34 insertions(+), 14 deletions(-)

Gentle ping... Could you review/pick this series? MFD amd IIO bits are already ACKed

Quoted 8 lines
Quoted 2 lines

MFD patches are reviewed "for my own reference" meaning that we haven't yet agreed on a merge plan yet.

I think this series makes sense to be pushed through a single tree as opposed to being spread between 3, even if it could technically be possible. It looks like Jonathan is fine with going it through either his or some other tree, I am fine with it going through MFD. I just Acked the 2 input-related patches.

Just to confirm, MFD is fine for iio patches. That driver isn't a hotbed of activity ;)

Jonathan

Quoted 3 lines

Thanks.

#21 lore raw
In reply to Dmitry Torokhov
Quoted 35 lines · Dmitry Torokhov
Quoted 34 lines · Lee Jones
Quoted 31 lines · Vignesh R

Hi Dmitry,

Quoted 20 lines · Vignesh R

On AM335x, resistive TSC can wakeup the system from low power state. Currently, parent MFD device is marked as wakeup source, which is inaccurate as its the touch event generated by TSC thats the wakeup source. This series moves all wakeup related calls to operate on TSC device instead of MFD. It also marks TSC IRQ as wakeup capable, so that its not disabled during system suspend.

This series is based on Dmitry's comments here:
https://lkml.org/lkml/2018/4/24/65

There are many new patches in this series, hence did not mark this as v4.

Vignesh R (5):
mfd: ti_am335x_tscadc: Don't mark TSCADC MFD as wakeup capable
Input: ti_am335x_tsc: Mark TSC device as wakeup source
mfd: ti_am335x_tscadc: Keep ADC interface on if child is wakeup
capable
iio: adc: ti_am335x_adc: Disable ADC during suspend unconditionally
Input: ti_am335x_tsc: Mark IRQ as wakeup capable

Quoted 5 lines
 drivers/iio/adc/ti_am335x_adc.c           | 12 ++++--------
 drivers/input/touchscreen/ti_am335x_tsc.c | 22 +++++++++++++++++-----
 drivers/mfd/ti_am335x_tscadc.c            | 14 +++++++++++++-
 3 files changed, 34 insertions(+), 14 deletions(-)

Gentle ping... Could you review/pick this series? MFD amd IIO bits are already ACKed

Quoted 7 lines
Quoted 2 lines

MFD patches are reviewed "for my own reference" meaning that we haven't yet agreed on a merge plan yet.

I think this series makes sense to be pushed through a single tree as opposed to being spread between 3, even if it could technically be possible. It looks like Jonathan is fine with going it through either his or some other tree, I am fine with it going through MFD.

I'm happy either way.

Quoted 1 line

I just Acked the 2 input-related patches.

Thanks Dmitry.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
author
#22 lore raw
Quoted 40 lines · Lee Jones
Quoted 38 lines · Dmitry Torokhov
Quoted 36 lines · Lee Jones
Quoted 23 lines · Vignesh R

Hi Dmitry,

Quoted 20 lines · Vignesh R

On AM335x, resistive TSC can wakeup the system from low power state. Currently, parent MFD device is marked as wakeup source, which is inaccurate as its the touch event generated by TSC thats the wakeup source. This series moves all wakeup related calls to operate on TSC device instead of MFD. It also marks TSC IRQ as wakeup capable, so that its not disabled during system suspend.

This series is based on Dmitry's comments here:
https://lkml.org/lkml/2018/4/24/65

There are many new patches in this series, hence did not mark this as v4.

Vignesh R (5):
mfd: ti_am335x_tscadc: Don't mark TSCADC MFD as wakeup capable
Input: ti_am335x_tsc: Mark TSC device as wakeup source
mfd: ti_am335x_tscadc: Keep ADC interface on if child is wakeup
capable
iio: adc: ti_am335x_adc: Disable ADC during suspend unconditionally
Input: ti_am335x_tsc: Mark IRQ as wakeup capable

Quoted 8 lines
Quoted 5 lines
 drivers/iio/adc/ti_am335x_adc.c           | 12 ++++--------
 drivers/input/touchscreen/ti_am335x_tsc.c | 22 +++++++++++++++++-----
 drivers/mfd/ti_am335x_tscadc.c            | 14 +++++++++++++-
 3 files changed, 34 insertions(+), 14 deletions(-)

Gentle ping... Could you review/pick this series? MFD amd IIO bits are already ACKed

MFD patches are reviewed "for my own reference" meaning that we haven't yet agreed on a merge plan yet.

Quoted 7 lines
Quoted 4 lines

I think this series makes sense to be pushed through a single tree as opposed to being spread between 3, even if it could technically be possible. It looks like Jonathan is fine with going it through either his or some other tree, I am fine with it going through MFD.

I'm happy either way.

Thanks Dmitry, Jonathan and Lee Jones!

Could this be applied to one of the trees now? MFD perhaps?

Signature · 2 lines
Regards
Vignesh
#23 lore raw
Quoted 46 lines · Vignesh R
Quoted 45 lines · Lee Jones
Quoted 42 lines · Dmitry Torokhov
Quoted 31 lines · Lee Jones
Quoted 29 lines · Vignesh R

Hi Dmitry,

Quoted 25 lines · Vignesh R

On AM335x, resistive TSC can wakeup the system from low power state. Currently, parent MFD device is marked as wakeup source, which is inaccurate as its the touch event generated by TSC thats the wakeup source. This series moves all wakeup related calls to operate on TSC device instead of MFD. It also marks TSC IRQ as wakeup capable, so that its not disabled during system suspend.

This series is based on Dmitry's comments here:
https://lkml.org/lkml/2018/4/24/65

There are many new patches in this series, hence did not mark this as v4.

Vignesh R (5):
mfd: ti_am335x_tscadc: Don't mark TSCADC MFD as wakeup capable
Input: ti_am335x_tsc: Mark TSC device as wakeup source
mfd: ti_am335x_tscadc: Keep ADC interface on if child is wakeup
capable
iio: adc: ti_am335x_adc: Disable ADC during suspend unconditionally
Input: ti_am335x_tsc: Mark IRQ as wakeup capable

 drivers/iio/adc/ti_am335x_adc.c           | 12 ++++--------
 drivers/input/touchscreen/ti_am335x_tsc.c | 22 +++++++++++++++++-----
 drivers/mfd/ti_am335x_tscadc.c            | 14 +++++++++++++-
 3 files changed, 34 insertions(+), 14 deletions(-)
Quoted 5 lines
Quoted 2 lines

Gentle ping... Could you review/pick this series? MFD amd IIO bits are already ACKed

MFD patches are reviewed "for my own reference" meaning that we haven't yet agreed on a merge plan yet.

I think this series makes sense to be pushed through a single tree as opposed to being spread between 3, even if it could technically be possible. It looks like Jonathan is fine with going it through either his or some other tree, I am fine with it going through MFD.

Quoted 5 lines
Quoted 2 lines

I'm happy either way.

Thanks Dmitry, Jonathan and Lee Jones!

Could this be applied to one of the trees now? MFD perhaps?

It'll be applied, when it's applied. ;)

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
author
#24 lore raw

Hi Lee,

On Wednesday 25 July 2018 10:56 AM, Lee Jones wrote:
[...]

Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 25 lines
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines

Vignesh R (5):
mfd: ti_am335x_tscadc: Don't mark TSCADC MFD as wakeup capable
Input: ti_am335x_tsc: Mark TSC device as wakeup source
mfd: ti_am335x_tscadc: Keep ADC interface on if child is wakeup
capable
iio: adc: ti_am335x_adc: Disable ADC during suspend unconditionally
Input: ti_am335x_tsc: Mark IRQ as wakeup capable

 drivers/iio/adc/ti_am335x_adc.c           | 12 ++++--------
 drivers/input/touchscreen/ti_am335x_tsc.c | 22 +++++++++++++++++-----
 drivers/mfd/ti_am335x_tscadc.c            | 14 +++++++++++++-
 3 files changed, 34 insertions(+), 14 deletions(-)
Quoted 5 lines
Quoted 2 lines

Gentle ping... Could you review/pick this series? MFD amd IIO bits are already ACKed

MFD patches are reviewed "for my own reference" meaning that we haven't yet agreed on a merge plan yet.

I think this series makes sense to be pushed through a single tree as opposed to being spread between 3, even if it could technically be possible. It looks like Jonathan is fine with going it through either his or some other tree, I am fine with it going through MFD.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I'm happy either way.

Thanks Dmitry, Jonathan and Lee Jones!

Could this be applied to one of the trees now? MFD perhaps?

It'll be applied, when it's applied. ;)

I see that this series was not picked up for v4.19. Could you consider this series for v4.20? Patches apply cleanly against linux-next.

Signature · 2 lines
Regards
Vignesh
author
#25 lore raw
Quoted 32 lines · Vignesh R

Hi Lee,

On Wednesday 25 July 2018 10:56 AM, Lee Jones wrote:
[...]

Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 9 lines

Vignesh R (5):
mfd: ti_am335x_tscadc: Don't mark TSCADC MFD as wakeup capable
Input: ti_am335x_tsc: Mark TSC device as wakeup source
mfd: ti_am335x_tscadc: Keep ADC interface on if child is wakeup
capable
iio: adc: ti_am335x_adc: Disable ADC during suspend unconditionally
Input: ti_am335x_tsc: Mark IRQ as wakeup capable

Quoted 5 lines
 drivers/iio/adc/ti_am335x_adc.c           | 12 ++++--------
 drivers/input/touchscreen/ti_am335x_tsc.c | 22 +++++++++++++++++-----
 drivers/mfd/ti_am335x_tscadc.c            | 14 +++++++++++++-
 3 files changed, 34 insertions(+), 14 deletions(-)

Gentle ping... Could you review/pick this series? MFD amd IIO bits are already ACKed

Quoted 7 lines
Quoted 2 lines

MFD patches are reviewed "for my own reference" meaning that we haven't yet agreed on a merge plan yet.

I think this series makes sense to be pushed through a single tree as opposed to being spread between 3, even if it could technically be possible. It looks like Jonathan is fine with going it through either his or some other tree, I am fine with it going through MFD.

I'm happy either way.

Quoted 10 lines
Quoted 5 lines
Quoted 3 lines

Thanks Dmitry, Jonathan and Lee Jones!

Could this be applied to one of the trees now? MFD perhaps?

It'll be applied, when it's applied. ;)

I see that this series was not picked up for v4.19. Could you consider this series for v4.20? Patches apply cleanly against linux-next.

Gentle ping...

Signature · 2 lines
Regards
Vignesh
Applied
#3 lore raw

Re: [PATCH 1/5] mfd: ti_am335x_tscadc: Don't mark TSCADC MFD as wakeup capable

In reply to Vignesh R
Quoted 10 lines · Vignesh R

Currently tscadc MFD is marked as wakeup capable which incorrect because, its actually touch event by child TSC device that wakes up the system. Therefore, remove device_init_wakeup() call that marks TSCADC device as wakeup capable in favor of moving to mark TSC input device as wakeup capable later.

---
 drivers/mfd/ti_am335x_tscadc.c | 1 -
 1 file changed, 1 deletion(-)

Applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Applied
#6 lore raw

Re: [PATCH 2/5] Input: ti_am335x_tsc: Mark TSC device as wakeup source

In reply to Vignesh R
Quoted 7 lines · Vignesh R

Instead of TSCADC MFD device, mark TSC as wakeup source and change all wakeup related PM calls to operate on TSC device.

---
 drivers/input/touchscreen/ti_am335x_tsc.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

Applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Applied
#9 lore raw

Re: [PATCH 3/5] mfd: ti_am335x_tscadc: Keep ADC interface on if child is wakeup capable

In reply to Vignesh R
Quoted 8 lines · Vignesh R

If a child device like touchscreen is wakeup capable, then keep ADC interface on, so that a touching resistive screen will generate wakeup event to the system.

---
 drivers/mfd/ti_am335x_tscadc.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Applied
#13 lore raw

Re: [PATCH 4/5] iio: adc: ti_am335x_adc: Disable ADC during suspend unconditionally

In reply to Vignesh R
Quoted 9 lines · Vignesh R

Parent MFD device takes care of enabling ADC interface whenever touchscreen is marked wakeup capable. Therefore, unconditionally disable ADC interface during system suspend to save power in case of system with just ADC and no TSC.

---
 drivers/iio/adc/ti_am335x_adc.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Applied
#16 lore raw

Re: [PATCH 5/5] Input: ti_am335x_tsc: Mark IRQ as wakeup capable

In reply to Vignesh R
Quoted 8 lines · Vignesh R

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.

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

Applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#26 lore raw

[GIT PULL] Immutable branch between MFD, IIO and Input due for the v4.20 merge window

In reply to Vignesh R

Enjoy!

The following changes since commit 5b394b2ddf0347bef56e50c69a58773c94343ff3:

Linux 4.19-rc1 (2018-08-26 14:11:59 -0700)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git ib-mfd-iio-input-v4.20

for you to fetch changes up to 7a39915b723ae46e78c5189dfb3fc889df976a8d:

Input: ti_am335x_tsc: Mark IRQ as wakeup capable (2018-10-09 11:28:31 +0100)

----------------------------------------------------------------
Immutable branch between MFD, IIO and Input due for the v4.20 merge window

----------------------------------------------------------------
Vignesh R (5):
mfd: ti_am335x_tscadc: Don't mark TSCADC MFD as wakeup capable
Input: ti_am335x_tsc: Mark TSC device as wakeup source
mfd: ti_am335x_tscadc: Keep ADC interface on if child is wakeup capable
iio: adc: ti_am335x_adc: Disable ADC during suspend unconditionally
Input: ti_am335x_tsc: Mark IRQ as wakeup capable

 drivers/iio/adc/ti_am335x_adc.c           | 12 ++++--------
 drivers/input/touchscreen/ti_am335x_tsc.c | 22 +++++++++++++++++-----
 drivers/mfd/ti_am335x_tscadc.c            | 14 +++++++++++++-
 3 files changed, 34 insertions(+), 14 deletions(-)
Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog