linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] PinePhone volume key (LRADC) wakeup support
@ 2021-01-13  4:05 Samuel Holland
  2021-01-13  4:05 ` [PATCH v2 1/3] dt-bindings: sun4i-a10-lradc-keys: Accept wakeup-source property Samuel Holland
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Samuel Holland @ 2021-01-13  4:05 UTC (permalink / raw)
  To: Hans de Goede, Dmitry Torokhov, Rob Herring, Maxime Ripard,
	Chen-Yu Tsai, Jernej Skrabec
  Cc: devicetree, linux-input, linux-kernel, linux-sunxi, Samuel Holland

This series allows the volume keys on the PinePhone to wake up the
device. As pointed out for v1, wakeup should only be enabled when a
"wakeup-source" property is present, so v2 requires DT and binding
changes in addition to the driver change.

Changes since v1:
  - Add requisite DT binding change
  - Only add wakeup capability if "wakeup-source" is present
  - Warn but do not error out if setting the wake IRQ fails
  - Add "wakeup-source" property to PinePhone device tree

Ondrej Jirman (1):
  input: sun4i-lradc-keys -  Add wakup support

Samuel Holland (2):
  dt-bindings: sun4i-a10-lradc-keys: Accept wakeup-source property
  arm64: dts: allwinner: pinephone: Support volume key wakeup

 .../input/allwinner,sun4i-a10-lradc-keys.yaml |  2 ++
 .../dts/allwinner/sun50i-a64-pinephone.dtsi   |  1 +
 drivers/input/keyboard/sun4i-lradc-keys.c     | 22 +++++++++++++++----
 3 files changed, 21 insertions(+), 4 deletions(-)

-- 
2.26.2


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

* [PATCH v2 1/3] dt-bindings: sun4i-a10-lradc-keys: Accept wakeup-source property
  2021-01-13  4:05 [PATCH v2 0/3] PinePhone volume key (LRADC) wakeup support Samuel Holland
@ 2021-01-13  4:05 ` Samuel Holland
  2021-01-25 19:14   ` Rob Herring
  2021-01-13  4:05 ` [PATCH v2 2/3] input: sun4i-lradc-keys - Add wakup support Samuel Holland
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Samuel Holland @ 2021-01-13  4:05 UTC (permalink / raw)
  To: Hans de Goede, Dmitry Torokhov, Rob Herring, Maxime Ripard,
	Chen-Yu Tsai, Jernej Skrabec
  Cc: devicetree, linux-input, linux-kernel, linux-sunxi, Samuel Holland

The LRADC provides an interrupt that can be used to wake the system.
Signify this by accepting a "wakeup-source" property in the binding.

Signed-off-by: Samuel Holland <samuel@sholland.org>
---
 .../bindings/input/allwinner,sun4i-a10-lradc-keys.yaml          | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/allwinner,sun4i-a10-lradc-keys.yaml b/Documentation/devicetree/bindings/input/allwinner,sun4i-a10-lradc-keys.yaml
index cffd02028d02..d74f2002409e 100644
--- a/Documentation/devicetree/bindings/input/allwinner,sun4i-a10-lradc-keys.yaml
+++ b/Documentation/devicetree/bindings/input/allwinner,sun4i-a10-lradc-keys.yaml
@@ -29,6 +29,8 @@ properties:
     description:
       Regulator for the LRADC reference voltage
 
+  wakeup-source: true
+
 patternProperties:
   "^button-[0-9]+$":
     type: object
-- 
2.26.2


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

* [PATCH v2 2/3] input: sun4i-lradc-keys -  Add wakup support
  2021-01-13  4:05 [PATCH v2 0/3] PinePhone volume key (LRADC) wakeup support Samuel Holland
  2021-01-13  4:05 ` [PATCH v2 1/3] dt-bindings: sun4i-a10-lradc-keys: Accept wakeup-source property Samuel Holland
@ 2021-01-13  4:05 ` Samuel Holland
  2021-01-13  4:05 ` [PATCH v2 3/3] arm64: dts: allwinner: pinephone: Support volume key wakeup Samuel Holland
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Samuel Holland @ 2021-01-13  4:05 UTC (permalink / raw)
  To: Hans de Goede, Dmitry Torokhov, Rob Herring, Maxime Ripard,
	Chen-Yu Tsai, Jernej Skrabec
  Cc: devicetree, linux-input, linux-kernel, linux-sunxi,
	Samuel Holland, Ondrej Jirman

From: Ondrej Jirman <megous@megous.com>

Allow the driver to wake the system on key press if the "wakeup-source"
property is provided in the device tree. Using the LRADC as a wakeup
source requires keeping the AVCC domain active during sleep. Since this
has a nontrivial impact on power consumption (sometimes doubling it),
disable the LRADC wakeup source by default.

Signed-off-by: Ondrej Jirman <megous@megous.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
 drivers/input/keyboard/sun4i-lradc-keys.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/input/keyboard/sun4i-lradc-keys.c b/drivers/input/keyboard/sun4i-lradc-keys.c
index 4a796bed48ac..a1eb2001c088 100644
--- a/drivers/input/keyboard/sun4i-lradc-keys.c
+++ b/drivers/input/keyboard/sun4i-lradc-keys.c
@@ -22,6 +22,8 @@
 #include <linux/module.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
+#include <linux/pm_wakeirq.h>
+#include <linux/pm_wakeup.h>
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
 
@@ -226,8 +228,7 @@ static int sun4i_lradc_probe(struct platform_device *pdev)
 {
 	struct sun4i_lradc_data *lradc;
 	struct device *dev = &pdev->dev;
-	int i;
-	int error;
+	int error, i, irq;
 
 	lradc = devm_kzalloc(dev, sizeof(struct sun4i_lradc_data), GFP_KERNEL);
 	if (!lradc)
@@ -272,8 +273,13 @@ static int sun4i_lradc_probe(struct platform_device *pdev)
 	if (IS_ERR(lradc->base))
 		return PTR_ERR(lradc->base);
 
-	error = devm_request_irq(dev, platform_get_irq(pdev, 0),
-				 sun4i_lradc_irq, 0,
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0) {
+		dev_err(&pdev->dev, "Failed to get IRQ\n");
+		return irq;
+	}
+
+	error = devm_request_irq(dev, irq, sun4i_lradc_irq, 0,
 				 "sun4i-a10-lradc-keys", lradc);
 	if (error)
 		return error;
@@ -282,6 +288,14 @@ static int sun4i_lradc_probe(struct platform_device *pdev)
 	if (error)
 		return error;
 
+	if (device_property_read_bool(dev, "wakeup-source")) {
+		device_set_wakeup_capable(dev, true);
+
+		error = dev_pm_set_wake_irq(dev, irq);
+		if (error)
+			dev_warn(dev, "Failed to set wake IRQ\n");
+	}
+
 	return 0;
 }
 
-- 
2.26.2


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

* [PATCH v2 3/3] arm64: dts: allwinner: pinephone: Support volume key wakeup
  2021-01-13  4:05 [PATCH v2 0/3] PinePhone volume key (LRADC) wakeup support Samuel Holland
  2021-01-13  4:05 ` [PATCH v2 1/3] dt-bindings: sun4i-a10-lradc-keys: Accept wakeup-source property Samuel Holland
  2021-01-13  4:05 ` [PATCH v2 2/3] input: sun4i-lradc-keys - Add wakup support Samuel Holland
@ 2021-01-13  4:05 ` Samuel Holland
  2021-01-13  8:14 ` [PATCH v2 0/3] PinePhone volume key (LRADC) wakeup support Hans de Goede
  2021-01-13  8:28 ` Maxime Ripard
  4 siblings, 0 replies; 7+ messages in thread
From: Samuel Holland @ 2021-01-13  4:05 UTC (permalink / raw)
  To: Hans de Goede, Dmitry Torokhov, Rob Herring, Maxime Ripard,
	Chen-Yu Tsai, Jernej Skrabec
  Cc: devicetree, linux-input, linux-kernel, linux-sunxi, Samuel Holland

PinePhone volume keys are connected to the LRADC in the A64. Users may
want to use them to wake the device from sleep. Support this by
declaring the LRADC as a wakeup source.

Signed-off-by: Samuel Holland <samuel@sholland.org>
---
 arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
index 2dfe9bae8c67..7f37f9fea0ab 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
@@ -196,6 +196,7 @@ &i2c2 {
 
 &lradc {
 	vref-supply = <&reg_aldo3>;
+	wakeup-source;
 	status = "okay";
 
 	button-200 {
-- 
2.26.2


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

* Re: [PATCH v2 0/3] PinePhone volume key (LRADC) wakeup support
  2021-01-13  4:05 [PATCH v2 0/3] PinePhone volume key (LRADC) wakeup support Samuel Holland
                   ` (2 preceding siblings ...)
  2021-01-13  4:05 ` [PATCH v2 3/3] arm64: dts: allwinner: pinephone: Support volume key wakeup Samuel Holland
@ 2021-01-13  8:14 ` Hans de Goede
  2021-01-13  8:28 ` Maxime Ripard
  4 siblings, 0 replies; 7+ messages in thread
From: Hans de Goede @ 2021-01-13  8:14 UTC (permalink / raw)
  To: Samuel Holland, Dmitry Torokhov, Rob Herring, Maxime Ripard,
	Chen-Yu Tsai, Jernej Skrabec
  Cc: devicetree, linux-input, linux-kernel, linux-sunxi

Hi,

On 1/13/21 5:05 AM, Samuel Holland wrote:
> This series allows the volume keys on the PinePhone to wake up the
> device. As pointed out for v1, wakeup should only be enabled when a
> "wakeup-source" property is present, so v2 requires DT and binding
> changes in addition to the driver change.
> 
> Changes since v1:
>   - Add requisite DT binding change
>   - Only add wakeup capability if "wakeup-source" is present
>   - Warn but do not error out if setting the wake IRQ fails
>   - Add "wakeup-source" property to PinePhone device tree
> 
> Ondrej Jirman (1):
>   input: sun4i-lradc-keys -  Add wakup support
> 
> Samuel Holland (2):
>   dt-bindings: sun4i-a10-lradc-keys: Accept wakeup-source property
>   arm64: dts: allwinner: pinephone: Support volume key wakeup

Thanks, the entire series looks good to me:

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

Regards,

Hans


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

* Re: [PATCH v2 0/3] PinePhone volume key (LRADC) wakeup support
  2021-01-13  4:05 [PATCH v2 0/3] PinePhone volume key (LRADC) wakeup support Samuel Holland
                   ` (3 preceding siblings ...)
  2021-01-13  8:14 ` [PATCH v2 0/3] PinePhone volume key (LRADC) wakeup support Hans de Goede
@ 2021-01-13  8:28 ` Maxime Ripard
  4 siblings, 0 replies; 7+ messages in thread
From: Maxime Ripard @ 2021-01-13  8:28 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Hans de Goede, Dmitry Torokhov, Rob Herring, Chen-Yu Tsai,
	Jernej Skrabec, devicetree, linux-input, linux-kernel,
	linux-sunxi

[-- Attachment #1: Type: text/plain, Size: 1141 bytes --]

On Tue, Jan 12, 2021 at 10:05:39PM -0600, Samuel Holland wrote:
> This series allows the volume keys on the PinePhone to wake up the
> device. As pointed out for v1, wakeup should only be enabled when a
> "wakeup-source" property is present, so v2 requires DT and binding
> changes in addition to the driver change.
> 
> Changes since v1:
>   - Add requisite DT binding change
>   - Only add wakeup capability if "wakeup-source" is present
>   - Warn but do not error out if setting the wake IRQ fails
>   - Add "wakeup-source" property to PinePhone device tree
> 
> Ondrej Jirman (1):
>   input: sun4i-lradc-keys -  Add wakup support
> 
> Samuel Holland (2):
>   dt-bindings: sun4i-a10-lradc-keys: Accept wakeup-source property
>   arm64: dts: allwinner: pinephone: Support volume key wakeup
> 
>  .../input/allwinner,sun4i-a10-lradc-keys.yaml |  2 ++
>  .../dts/allwinner/sun50i-a64-pinephone.dtsi   |  1 +
>  drivers/input/keyboard/sun4i-lradc-keys.c     | 22 +++++++++++++++----
>  3 files changed, 21 insertions(+), 4 deletions(-)

Acked-by: Maxime Ripard <mripard@kernel.org>

I've applied patch 3

Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [PATCH v2 1/3] dt-bindings: sun4i-a10-lradc-keys: Accept wakeup-source property
  2021-01-13  4:05 ` [PATCH v2 1/3] dt-bindings: sun4i-a10-lradc-keys: Accept wakeup-source property Samuel Holland
@ 2021-01-25 19:14   ` Rob Herring
  0 siblings, 0 replies; 7+ messages in thread
From: Rob Herring @ 2021-01-25 19:14 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Maxime Ripard, Rob Herring, Chen-Yu Tsai, devicetree,
	linux-input, linux-sunxi, Dmitry Torokhov, linux-kernel,
	Hans de Goede, Jernej Skrabec

On Tue, 12 Jan 2021 22:05:40 -0600, Samuel Holland wrote:
> The LRADC provides an interrupt that can be used to wake the system.
> Signify this by accepting a "wakeup-source" property in the binding.
> 
> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
>  .../bindings/input/allwinner,sun4i-a10-lradc-keys.yaml          | 2 ++
>  1 file changed, 2 insertions(+)
> 

Acked-by: Rob Herring <robh@kernel.org>

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

end of thread, other threads:[~2021-01-25 19:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-13  4:05 [PATCH v2 0/3] PinePhone volume key (LRADC) wakeup support Samuel Holland
2021-01-13  4:05 ` [PATCH v2 1/3] dt-bindings: sun4i-a10-lradc-keys: Accept wakeup-source property Samuel Holland
2021-01-25 19:14   ` Rob Herring
2021-01-13  4:05 ` [PATCH v2 2/3] input: sun4i-lradc-keys - Add wakup support Samuel Holland
2021-01-13  4:05 ` [PATCH v2 3/3] arm64: dts: allwinner: pinephone: Support volume key wakeup Samuel Holland
2021-01-13  8:14 ` [PATCH v2 0/3] PinePhone volume key (LRADC) wakeup support Hans de Goede
2021-01-13  8:28 ` Maxime Ripard

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