linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Input: axp20x-pek wakeup enablement
@ 2020-01-15  5:12 Samuel Holland
  2020-01-15  5:12 ` [PATCH v2 1/2] Input: axp20x-pek - Respect userspace wakeup configuration Samuel Holland
  2020-01-15  5:12 ` [PATCH v2 2/2] Input: axp20x-pek - Enable wakeup for all AXP variants Samuel Holland
  0 siblings, 2 replies; 6+ messages in thread
From: Samuel Holland @ 2020-01-15  5:12 UTC (permalink / raw)
  To: Dmitry Torokhov, Hans de Goede, Chen-Yu Tsai
  Cc: linux-input, linux-kernel, linux-sunxi, Samuel Holland

This series allows enabling or disabling wakeup via the power button on
X-Powers PMICs, for all AXP2xx/AXP8xx variants. This v2 of the patch
series keeps the existing behavior of the AXP288 variant used on x86
platforms.

Changes since v1:
 - Drop patch 1
 - Use __maybe_unused instead of "#ifdef CONFIG_PM_SLEEP" [patch 2]
 - Add Reviewed-by [patch 3]

Samuel Holland (2):
  Input: axp20x-pek - Respect userspace wakeup configuration
  Input: axp20x-pek - Enable wakeup for all AXP variants

 drivers/input/misc/axp20x-pek.c | 38 +++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

-- 
2.23.0


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

* [PATCH v2 1/2] Input: axp20x-pek - Respect userspace wakeup configuration
  2020-01-15  5:12 [PATCH v2 0/2] Input: axp20x-pek wakeup enablement Samuel Holland
@ 2020-01-15  5:12 ` Samuel Holland
  2020-01-15 10:50   ` Hans de Goede
  2020-01-15  5:12 ` [PATCH v2 2/2] Input: axp20x-pek - Enable wakeup for all AXP variants Samuel Holland
  1 sibling, 1 reply; 6+ messages in thread
From: Samuel Holland @ 2020-01-15  5:12 UTC (permalink / raw)
  To: Dmitry Torokhov, Hans de Goede, Chen-Yu Tsai
  Cc: linux-input, linux-kernel, linux-sunxi, Samuel Holland

Unlike most other power button drivers, this driver unconditionally
enables its wakeup IRQ. It should be using device_may_wakeup() to
respect the userspace configuration of wakeup sources.

Because the AXP20x MFD device uses regmap-irq, the AXP20x PEK IRQs are
nested off of regmap-irq's threaded interrupt handler. The device core
ignores such interrupts, so to actually disable wakeup, we must
explicitly disable all non-wakeup interrupts during suspend.

Signed-off-by: Samuel Holland <samuel@sholland.org>
---
 drivers/input/misc/axp20x-pek.c | 37 ++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
index 17c1cca74498..0ace3fe3d7dc 100644
--- a/drivers/input/misc/axp20x-pek.c
+++ b/drivers/input/misc/axp20x-pek.c
@@ -280,7 +280,7 @@ static int axp20x_pek_probe_input_device(struct axp20x_pek *axp20x_pek,
 	}
 
 	if (axp20x_pek->axp20x->variant == AXP288_ID)
-		enable_irq_wake(axp20x_pek->irq_dbr);
+		device_init_wakeup(&pdev->dev, true);
 
 	return 0;
 }
@@ -352,6 +352,40 @@ static int axp20x_pek_probe(struct platform_device *pdev)
 	return 0;
 }
 
+static int __maybe_unused axp20x_pek_suspend(struct device *dev)
+{
+	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
+
+	/*
+	 * As nested threaded IRQs are not automatically disabled during
+	 * suspend, we must explicitly disable non-wakeup IRQs.
+	 */
+	if (device_may_wakeup(dev)) {
+		enable_irq_wake(axp20x_pek->irq_dbf);
+		enable_irq_wake(axp20x_pek->irq_dbr);
+	} else {
+		disable_irq(axp20x_pek->irq_dbf);
+		disable_irq(axp20x_pek->irq_dbr);
+	}
+
+	return 0;
+}
+
+static int __maybe_unused axp20x_pek_resume(struct device *dev)
+{
+	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
+
+	if (device_may_wakeup(dev)) {
+		disable_irq_wake(axp20x_pek->irq_dbf);
+		disable_irq_wake(axp20x_pek->irq_dbr);
+	} else {
+		enable_irq(axp20x_pek->irq_dbf);
+		enable_irq(axp20x_pek->irq_dbr);
+	}
+
+	return 0;
+}
+
 static int __maybe_unused axp20x_pek_resume_noirq(struct device *dev)
 {
 	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
@@ -371,6 +405,7 @@ static int __maybe_unused axp20x_pek_resume_noirq(struct device *dev)
 }
 
 static const struct dev_pm_ops axp20x_pek_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(axp20x_pek_suspend, axp20x_pek_resume)
 #ifdef CONFIG_PM_SLEEP
 	.resume_noirq = axp20x_pek_resume_noirq,
 #endif
-- 
2.23.0


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

* [PATCH v2 2/2] Input: axp20x-pek - Enable wakeup for all AXP variants
  2020-01-15  5:12 [PATCH v2 0/2] Input: axp20x-pek wakeup enablement Samuel Holland
  2020-01-15  5:12 ` [PATCH v2 1/2] Input: axp20x-pek - Respect userspace wakeup configuration Samuel Holland
@ 2020-01-15  5:12 ` Samuel Holland
  2020-01-22  6:04   ` Dmitry Torokhov
  1 sibling, 1 reply; 6+ messages in thread
From: Samuel Holland @ 2020-01-15  5:12 UTC (permalink / raw)
  To: Dmitry Torokhov, Hans de Goede, Chen-Yu Tsai
  Cc: linux-input, linux-kernel, linux-sunxi, Samuel Holland

There are many devices, including several mobile battery-powered
devices, using other AXP variants as their PMIC. Allow them to use
the power key as a wakeup source.

Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
 drivers/input/misc/axp20x-pek.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
index 0ace3fe3d7dc..1872607e87c3 100644
--- a/drivers/input/misc/axp20x-pek.c
+++ b/drivers/input/misc/axp20x-pek.c
@@ -279,8 +279,7 @@ static int axp20x_pek_probe_input_device(struct axp20x_pek *axp20x_pek,
 		return error;
 	}
 
-	if (axp20x_pek->axp20x->variant == AXP288_ID)
-		device_init_wakeup(&pdev->dev, true);
+	device_init_wakeup(&pdev->dev, true);
 
 	return 0;
 }
-- 
2.23.0


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

* Re: [PATCH v2 1/2] Input: axp20x-pek - Respect userspace wakeup configuration
  2020-01-15  5:12 ` [PATCH v2 1/2] Input: axp20x-pek - Respect userspace wakeup configuration Samuel Holland
@ 2020-01-15 10:50   ` Hans de Goede
  2020-01-22  6:04     ` Dmitry Torokhov
  0 siblings, 1 reply; 6+ messages in thread
From: Hans de Goede @ 2020-01-15 10:50 UTC (permalink / raw)
  To: Samuel Holland, Dmitry Torokhov, Chen-Yu Tsai
  Cc: linux-input, linux-kernel, linux-sunxi

Hi,

On 15-01-2020 06:12, Samuel Holland wrote:
> Unlike most other power button drivers, this driver unconditionally
> enables its wakeup IRQ. It should be using device_may_wakeup() to
> respect the userspace configuration of wakeup sources.
> 
> Because the AXP20x MFD device uses regmap-irq, the AXP20x PEK IRQs are
> nested off of regmap-irq's threaded interrupt handler. The device core
> ignores such interrupts, so to actually disable wakeup, we must
> explicitly disable all non-wakeup interrupts during suspend.
> 
> Signed-off-by: Samuel Holland <samuel@sholland.org>

Patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> ---
>   drivers/input/misc/axp20x-pek.c | 37 ++++++++++++++++++++++++++++++++-
>   1 file changed, 36 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
> index 17c1cca74498..0ace3fe3d7dc 100644
> --- a/drivers/input/misc/axp20x-pek.c
> +++ b/drivers/input/misc/axp20x-pek.c
> @@ -280,7 +280,7 @@ static int axp20x_pek_probe_input_device(struct axp20x_pek *axp20x_pek,
>   	}
>   
>   	if (axp20x_pek->axp20x->variant == AXP288_ID)
> -		enable_irq_wake(axp20x_pek->irq_dbr);
> +		device_init_wakeup(&pdev->dev, true);
>   
>   	return 0;
>   }
> @@ -352,6 +352,40 @@ static int axp20x_pek_probe(struct platform_device *pdev)
>   	return 0;
>   }
>   
> +static int __maybe_unused axp20x_pek_suspend(struct device *dev)
> +{
> +	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
> +
> +	/*
> +	 * As nested threaded IRQs are not automatically disabled during
> +	 * suspend, we must explicitly disable non-wakeup IRQs.
> +	 */
> +	if (device_may_wakeup(dev)) {
> +		enable_irq_wake(axp20x_pek->irq_dbf);
> +		enable_irq_wake(axp20x_pek->irq_dbr);
> +	} else {
> +		disable_irq(axp20x_pek->irq_dbf);
> +		disable_irq(axp20x_pek->irq_dbr);
> +	}
> +
> +	return 0;
> +}
> +
> +static int __maybe_unused axp20x_pek_resume(struct device *dev)
> +{
> +	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
> +
> +	if (device_may_wakeup(dev)) {
> +		disable_irq_wake(axp20x_pek->irq_dbf);
> +		disable_irq_wake(axp20x_pek->irq_dbr);
> +	} else {
> +		enable_irq(axp20x_pek->irq_dbf);
> +		enable_irq(axp20x_pek->irq_dbr);
> +	}
> +
> +	return 0;
> +}
> +
>   static int __maybe_unused axp20x_pek_resume_noirq(struct device *dev)
>   {
>   	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
> @@ -371,6 +405,7 @@ static int __maybe_unused axp20x_pek_resume_noirq(struct device *dev)
>   }
>   
>   static const struct dev_pm_ops axp20x_pek_pm_ops = {
> +	SET_SYSTEM_SLEEP_PM_OPS(axp20x_pek_suspend, axp20x_pek_resume)
>   #ifdef CONFIG_PM_SLEEP
>   	.resume_noirq = axp20x_pek_resume_noirq,
>   #endif
> 


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

* Re: [PATCH v2 1/2] Input: axp20x-pek - Respect userspace wakeup configuration
  2020-01-15 10:50   ` Hans de Goede
@ 2020-01-22  6:04     ` Dmitry Torokhov
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2020-01-22  6:04 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Samuel Holland, Chen-Yu Tsai, linux-input, linux-kernel, linux-sunxi

On Wed, Jan 15, 2020 at 11:50:08AM +0100, Hans de Goede wrote:
> Hi,
> 
> On 15-01-2020 06:12, Samuel Holland wrote:
> > Unlike most other power button drivers, this driver unconditionally
> > enables its wakeup IRQ. It should be using device_may_wakeup() to
> > respect the userspace configuration of wakeup sources.
> > 
> > Because the AXP20x MFD device uses regmap-irq, the AXP20x PEK IRQs are
> > nested off of regmap-irq's threaded interrupt handler. The device core
> > ignores such interrupts, so to actually disable wakeup, we must
> > explicitly disable all non-wakeup interrupts during suspend.
> > 
> > Signed-off-by: Samuel Holland <samuel@sholland.org>
> 
> Patch looks good to me:
> 
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Applied, thank you.

> 
> Regards,
> 
> Hans
> 
> 
> 
> > ---
> >   drivers/input/misc/axp20x-pek.c | 37 ++++++++++++++++++++++++++++++++-
> >   1 file changed, 36 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
> > index 17c1cca74498..0ace3fe3d7dc 100644
> > --- a/drivers/input/misc/axp20x-pek.c
> > +++ b/drivers/input/misc/axp20x-pek.c
> > @@ -280,7 +280,7 @@ static int axp20x_pek_probe_input_device(struct axp20x_pek *axp20x_pek,
> >   	}
> >   	if (axp20x_pek->axp20x->variant == AXP288_ID)
> > -		enable_irq_wake(axp20x_pek->irq_dbr);
> > +		device_init_wakeup(&pdev->dev, true);
> >   	return 0;
> >   }
> > @@ -352,6 +352,40 @@ static int axp20x_pek_probe(struct platform_device *pdev)
> >   	return 0;
> >   }
> > +static int __maybe_unused axp20x_pek_suspend(struct device *dev)
> > +{
> > +	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
> > +
> > +	/*
> > +	 * As nested threaded IRQs are not automatically disabled during
> > +	 * suspend, we must explicitly disable non-wakeup IRQs.
> > +	 */
> > +	if (device_may_wakeup(dev)) {
> > +		enable_irq_wake(axp20x_pek->irq_dbf);
> > +		enable_irq_wake(axp20x_pek->irq_dbr);
> > +	} else {
> > +		disable_irq(axp20x_pek->irq_dbf);
> > +		disable_irq(axp20x_pek->irq_dbr);
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> > +static int __maybe_unused axp20x_pek_resume(struct device *dev)
> > +{
> > +	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
> > +
> > +	if (device_may_wakeup(dev)) {
> > +		disable_irq_wake(axp20x_pek->irq_dbf);
> > +		disable_irq_wake(axp20x_pek->irq_dbr);
> > +	} else {
> > +		enable_irq(axp20x_pek->irq_dbf);
> > +		enable_irq(axp20x_pek->irq_dbr);
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> >   static int __maybe_unused axp20x_pek_resume_noirq(struct device *dev)
> >   {
> >   	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
> > @@ -371,6 +405,7 @@ static int __maybe_unused axp20x_pek_resume_noirq(struct device *dev)
> >   }
> >   static const struct dev_pm_ops axp20x_pek_pm_ops = {
> > +	SET_SYSTEM_SLEEP_PM_OPS(axp20x_pek_suspend, axp20x_pek_resume)
> >   #ifdef CONFIG_PM_SLEEP
> >   	.resume_noirq = axp20x_pek_resume_noirq,
> >   #endif
> > 
> 

-- 
Dmitry

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

* Re: [PATCH v2 2/2] Input: axp20x-pek - Enable wakeup for all AXP variants
  2020-01-15  5:12 ` [PATCH v2 2/2] Input: axp20x-pek - Enable wakeup for all AXP variants Samuel Holland
@ 2020-01-22  6:04   ` Dmitry Torokhov
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2020-01-22  6:04 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Hans de Goede, Chen-Yu Tsai, linux-input, linux-kernel, linux-sunxi

On Tue, Jan 14, 2020 at 11:12:53PM -0600, Samuel Holland wrote:
> There are many devices, including several mobile battery-powered
> devices, using other AXP variants as their PMIC. Allow them to use
> the power key as a wakeup source.
> 
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Samuel Holland <samuel@sholland.org>

Applied, thank you.

> ---
>  drivers/input/misc/axp20x-pek.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
> index 0ace3fe3d7dc..1872607e87c3 100644
> --- a/drivers/input/misc/axp20x-pek.c
> +++ b/drivers/input/misc/axp20x-pek.c
> @@ -279,8 +279,7 @@ static int axp20x_pek_probe_input_device(struct axp20x_pek *axp20x_pek,
>  		return error;
>  	}
>  
> -	if (axp20x_pek->axp20x->variant == AXP288_ID)
> -		device_init_wakeup(&pdev->dev, true);
> +	device_init_wakeup(&pdev->dev, true);
>  
>  	return 0;
>  }
> -- 
> 2.23.0
> 

-- 
Dmitry

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

end of thread, other threads:[~2020-01-22  6:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-15  5:12 [PATCH v2 0/2] Input: axp20x-pek wakeup enablement Samuel Holland
2020-01-15  5:12 ` [PATCH v2 1/2] Input: axp20x-pek - Respect userspace wakeup configuration Samuel Holland
2020-01-15 10:50   ` Hans de Goede
2020-01-22  6:04     ` Dmitry Torokhov
2020-01-15  5:12 ` [PATCH v2 2/2] Input: axp20x-pek - Enable wakeup for all AXP variants Samuel Holland
2020-01-22  6:04   ` Dmitry Torokhov

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