All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] gpio-keys: Add support for specifying wakeup event action
@ 2018-02-10 11:09 ` Jeffy Chen
  0 siblings, 0 replies; 23+ messages in thread
From: Jeffy Chen @ 2018-02-10 11:09 UTC (permalink / raw)
  To: linux-kernel
  Cc: briannorris, dtor, dianders, Jeffy Chen, Arnd Bergmann,
	Joseph Lo, Rob Herring, Catalin Marinas, Emil Renner Berthing,
	Enric Balletbo i Serra, Heiko Stuebner, Brian Norris,
	Thomas Gleixner, Philippe Ombredanne, linux-rockchip,
	Kate Stewart, linux-input, Will Deacon, Matthias Kaehlcke,
	devicetree, stephen lu, Greg Kroah-Hartman, Arvind Yadav,
	linux-arm-kernel, Dmitry Torokhov, Mark Rutland


On chromebook kevin, we are using gpio-keys for pen insert event. But
we only want it to wakeup the system when ejecting the pen.

So we may need to change the interrupt trigger type during suspending.

Changes in v2:
Specify wakeup event action instead of irq trigger type as Brian
suggested.

Jeffy Chen (3):
  Input: gpio-keys - add support for wakeup event action
  Input: gpio-keys - allow setting wakeup event action in DT
  arm64: dts: rockchip: Avoid wakeup when inserting the pen

 .../devicetree/bindings/input/gpio-keys.txt        |  8 +++++++
 arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts  |  2 ++
 drivers/input/keyboard/gpio_keys.c                 | 27 ++++++++++++++++++++++
 include/linux/gpio_keys.h                          |  2 ++
 include/uapi/linux/input-event-codes.h             |  9 ++++++++
 5 files changed, 48 insertions(+)

-- 
2.11.0

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

* [PATCH v2 0/3] gpio-keys: Add support for specifying wakeup event action
@ 2018-02-10 11:09 ` Jeffy Chen
  0 siblings, 0 replies; 23+ messages in thread
From: Jeffy Chen @ 2018-02-10 11:09 UTC (permalink / raw)
  To: linux-kernel
  Cc: briannorris, dtor, dianders, Jeffy Chen, Arnd Bergmann,
	Joseph Lo, Rob Herring, Catalin Marinas, Emil Renner Berthing,
	Enric Balletbo i Serra, Heiko Stuebner, Brian Norris,
	Thomas Gleixner, Philippe Ombredanne, linux-rockchip,
	Kate Stewart, linux-input, Will Deacon, Matthias Kaehlcke,
	devicetree, stephen lu, Greg Kroah-Hartman


On chromebook kevin, we are using gpio-keys for pen insert event. But
we only want it to wakeup the system when ejecting the pen.

So we may need to change the interrupt trigger type during suspending.

Changes in v2:
Specify wakeup event action instead of irq trigger type as Brian
suggested.

Jeffy Chen (3):
  Input: gpio-keys - add support for wakeup event action
  Input: gpio-keys - allow setting wakeup event action in DT
  arm64: dts: rockchip: Avoid wakeup when inserting the pen

 .../devicetree/bindings/input/gpio-keys.txt        |  8 +++++++
 arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts  |  2 ++
 drivers/input/keyboard/gpio_keys.c                 | 27 ++++++++++++++++++++++
 include/linux/gpio_keys.h                          |  2 ++
 include/uapi/linux/input-event-codes.h             |  9 ++++++++
 5 files changed, 48 insertions(+)

-- 
2.11.0

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

* [PATCH v2 0/3] gpio-keys: Add support for specifying wakeup event action
@ 2018-02-10 11:09 ` Jeffy Chen
  0 siblings, 0 replies; 23+ messages in thread
From: Jeffy Chen @ 2018-02-10 11:09 UTC (permalink / raw)
  To: linux-arm-kernel


On chromebook kevin, we are using gpio-keys for pen insert event. But
we only want it to wakeup the system when ejecting the pen.

So we may need to change the interrupt trigger type during suspending.

Changes in v2:
Specify wakeup event action instead of irq trigger type as Brian
suggested.

Jeffy Chen (3):
  Input: gpio-keys - add support for wakeup event action
  Input: gpio-keys - allow setting wakeup event action in DT
  arm64: dts: rockchip: Avoid wakeup when inserting the pen

 .../devicetree/bindings/input/gpio-keys.txt        |  8 +++++++
 arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts  |  2 ++
 drivers/input/keyboard/gpio_keys.c                 | 27 ++++++++++++++++++++++
 include/linux/gpio_keys.h                          |  2 ++
 include/uapi/linux/input-event-codes.h             |  9 ++++++++
 5 files changed, 48 insertions(+)

-- 
2.11.0

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

* [PATCH v2 1/3] Input: gpio-keys - add support for wakeup event action
  2018-02-10 11:09 ` Jeffy Chen
  (?)
  (?)
@ 2018-02-10 11:09 ` Jeffy Chen
  2018-02-12 22:13   ` Brian Norris
  -1 siblings, 1 reply; 23+ messages in thread
From: Jeffy Chen @ 2018-02-10 11:09 UTC (permalink / raw)
  To: linux-kernel
  Cc: briannorris, dtor, dianders, Jeffy Chen, Enric Balletbo i Serra,
	Thomas Gleixner, Joseph Lo, stephen lu, Dmitry Torokhov,
	Kate Stewart, linux-input, Greg Kroah-Hartman,
	Philippe Ombredanne, Arvind Yadav

Add support for specifying event actions to trigger wakeup when using
the gpio-keys input device as a wakeup source.

This would allow the device to configure when to wakeup the system. For
example a gpio-keys input device for pen insert, may only want to wakeup
the system when ejecting the pen.

Suggested-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---

Changes in v2:
Specify wakeup event action instead of irq trigger type as Brian
suggested.

 drivers/input/keyboard/gpio_keys.c     | 27 +++++++++++++++++++++++++++
 include/linux/gpio_keys.h              |  2 ++
 include/uapi/linux/input-event-codes.h |  9 +++++++++
 3 files changed, 38 insertions(+)

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 87e613dc33b8..5c57339d3999 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -45,6 +45,8 @@ struct gpio_button_data {
 	unsigned int software_debounce;	/* in msecs, for GPIO-driven buttons */
 
 	unsigned int irq;
+	unsigned int irq_trigger_type;
+	unsigned int wakeup_trigger_type;
 	spinlock_t lock;
 	bool disabled;
 	bool key_pressed;
@@ -540,6 +542,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
 	}
 
 	if (bdata->gpiod) {
+		int active_low = gpiod_is_active_low(bdata->gpiod);
+
 		if (button->debounce_interval) {
 			error = gpiod_set_debounce(bdata->gpiod,
 					button->debounce_interval * 1000);
@@ -568,6 +572,16 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
 		isr = gpio_keys_gpio_isr;
 		irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
 
+		switch (button->wakeup_event_action) {
+		case EV_ACT_ASSERTED:
+			bdata->wakeup_trigger_type = active_low ?
+				IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING;
+			break;
+		case EV_ACT_DEASSERTED:
+			bdata->wakeup_trigger_type = active_low ?
+				IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
+			break;
+		}
 	} else {
 		if (!button->irq) {
 			dev_err(dev, "Found button without gpio or irq\n");
@@ -618,6 +632,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
 		return error;
 	}
 
+	bdata->irq_trigger_type = irq_get_trigger_type(bdata->irq);
+
 	return 0;
 }
 
@@ -718,6 +734,9 @@ gpio_keys_get_devtree_pdata(struct device *dev)
 			/* legacy name */
 			fwnode_property_read_bool(child, "gpio-key,wakeup");
 
+		fwnode_property_read_u32(child, "wakeup-event-action",
+					 &button->wakeup_event_action);
+
 		button->can_disable =
 			fwnode_property_read_bool(child, "linux,can-disable");
 
@@ -854,6 +873,10 @@ static int __maybe_unused gpio_keys_suspend(struct device *dev)
 	if (device_may_wakeup(dev)) {
 		for (i = 0; i < ddata->pdata->nbuttons; i++) {
 			struct gpio_button_data *bdata = &ddata->data[i];
+
+			if (bdata->button->wakeup && bdata->wakeup_trigger_type)
+				irq_set_irq_type(bdata->irq,
+						 bdata->wakeup_trigger_type);
 			if (bdata->button->wakeup)
 				enable_irq_wake(bdata->irq);
 			bdata->suspended = true;
@@ -878,6 +901,10 @@ static int __maybe_unused gpio_keys_resume(struct device *dev)
 	if (device_may_wakeup(dev)) {
 		for (i = 0; i < ddata->pdata->nbuttons; i++) {
 			struct gpio_button_data *bdata = &ddata->data[i];
+
+			if (bdata->button->wakeup && bdata->wakeup_trigger_type)
+				irq_set_irq_type(bdata->irq,
+						 bdata->irq_trigger_type);
 			if (bdata->button->wakeup)
 				disable_irq_wake(bdata->irq);
 			bdata->suspended = false;
diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h
index d06bf77400f1..7160df54a6fe 100644
--- a/include/linux/gpio_keys.h
+++ b/include/linux/gpio_keys.h
@@ -13,6 +13,7 @@ struct device;
  * @desc:		label that will be attached to button's gpio
  * @type:		input event type (%EV_KEY, %EV_SW, %EV_ABS)
  * @wakeup:		configure the button as a wake-up source
+ * @wakeup_event_action:	event action to trigger wakeup
  * @debounce_interval:	debounce ticks interval in msecs
  * @can_disable:	%true indicates that userspace is allowed to
  *			disable button via sysfs
@@ -26,6 +27,7 @@ struct gpio_keys_button {
 	const char *desc;
 	unsigned int type;
 	int wakeup;
+	int wakeup_event_action;
 	int debounce_interval;
 	bool can_disable;
 	int value;
diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
index 53fbae27b280..d7917b0bd438 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -32,6 +32,15 @@
 #define INPUT_PROP_CNT			(INPUT_PROP_MAX + 1)
 
 /*
+ * Event action types
+ */
+#define EV_ACT_ANY			0x00	/* asserted or deasserted */
+#define EV_ACT_ASSERTED			0x01	/* asserted */
+#define EV_ACT_DEASSERTED		0x02	/* deasserted */
+#define EV_ACT_MAX			0x02
+#define EV_ACT_CNT			(EV_ACT_MAX+1)
+
+/*
  * Event types
  */
 
-- 
2.11.0

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

* [PATCH v2 2/3] Input: gpio-keys - allow setting wakeup event action in DT
  2018-02-10 11:09 ` Jeffy Chen
                   ` (2 preceding siblings ...)
  (?)
@ 2018-02-10 11:09 ` Jeffy Chen
  2018-03-01 21:26   ` Rob Herring
  -1 siblings, 1 reply; 23+ messages in thread
From: Jeffy Chen @ 2018-02-10 11:09 UTC (permalink / raw)
  To: linux-kernel
  Cc: briannorris, dtor, dianders, Jeffy Chen, devicetree, Rob Herring,
	Dmitry Torokhov, linux-input, Mark Rutland

Allow specifying event actions to trigger wakeup when using the
gpio-keys input device as a wakeup source.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---

Changes in v2:
Specify wakeup event action instead of irq trigger type as Brian
suggested.

 Documentation/devicetree/bindings/input/gpio-keys.txt | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/gpio-keys.txt b/Documentation/devicetree/bindings/input/gpio-keys.txt
index a94940481e55..996ce84352cb 100644
--- a/Documentation/devicetree/bindings/input/gpio-keys.txt
+++ b/Documentation/devicetree/bindings/input/gpio-keys.txt
@@ -26,6 +26,14 @@ Optional subnode-properties:
 	  If not specified defaults to 5.
 	- wakeup-source: Boolean, button can wake-up the system.
 			 (Legacy property supported: "gpio-key,wakeup")
+	- wakeup-event-action: Specifies whether the key should wake the
+	  system when asserted, when deasserted, or both. This property is
+	  only valid for keys that wake up the system (e.g., when the
+	  "wakeup-source" property is also provided).
+	  Supported values are defined in linux-event-codes.h:
+		EV_ACT_ASSERTED		- asserted
+		EV_ACT_DEASSERTED	- deasserted
+		EV_ACT_ANY		- both asserted and deasserted
 	- linux,can-disable: Boolean, indicates that button is connected
 	  to dedicated (not shared) interrupt which can be disabled to
 	  suppress events from the button.
-- 
2.11.0

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

* [PATCH v2 3/3] arm64: dts: rockchip: Avoid wakeup when inserting the pen
@ 2018-02-10 11:09   ` Jeffy Chen
  0 siblings, 0 replies; 23+ messages in thread
From: Jeffy Chen @ 2018-02-10 11:09 UTC (permalink / raw)
  To: linux-kernel
  Cc: briannorris, dtor, dianders, Jeffy Chen, Matthias Kaehlcke,
	devicetree, Arnd Bergmann, Emil Renner Berthing, Heiko Stuebner,
	Brian Norris, linux-rockchip, Rob Herring, Dmitry Torokhov,
	linux-arm-kernel, Will Deacon, Mark Rutland, Catalin Marinas

Add wakeup event action for Pen Insert gpio key, to avoid wakeup when
inserting the pen.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---

Changes in v2:
Specify wakeup event action instead of irq trigger type as Brian
suggested.

 arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts b/arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts
index 191a6bcb1704..ef2de0057c5c 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts
@@ -134,6 +134,8 @@
 		gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
 		linux,code = <SW_PEN_INSERTED>;
 		linux,input-type = <EV_SW>;
+		/* Wakeup only when ejecting */
+		wakeup-event-action = <EV_ACT_DEASSERTED>;
 		wakeup-source;
 	};
 };
-- 
2.11.0

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

* [PATCH v2 3/3] arm64: dts: rockchip: Avoid wakeup when inserting the pen
@ 2018-02-10 11:09   ` Jeffy Chen
  0 siblings, 0 replies; 23+ messages in thread
From: Jeffy Chen @ 2018-02-10 11:09 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: briannorris-hpIqsD4AKlfQT0dZR+AlfA, dtor-hpIqsD4AKlfQT0dZR+AlfA,
	dianders-hpIqsD4AKlfQT0dZR+AlfA, Jeffy Chen, Matthias Kaehlcke,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Arnd Bergmann,
	Emil Renner Berthing, Heiko Stuebner, Brian Norris,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Rob Herring,
	Dmitry Torokhov,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Will Deacon,
	Mark Rutland, Catalin Marinas

Add wakeup event action for Pen Insert gpio key, to avoid wakeup when
inserting the pen.

Signed-off-by: Jeffy Chen <jeffy.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
---

Changes in v2:
Specify wakeup event action instead of irq trigger type as Brian
suggested.

 arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts b/arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts
index 191a6bcb1704..ef2de0057c5c 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts
@@ -134,6 +134,8 @@
 		gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
 		linux,code = <SW_PEN_INSERTED>;
 		linux,input-type = <EV_SW>;
+		/* Wakeup only when ejecting */
+		wakeup-event-action = <EV_ACT_DEASSERTED>;
 		wakeup-source;
 	};
 };
-- 
2.11.0


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2 3/3] arm64: dts: rockchip: Avoid wakeup when inserting the pen
@ 2018-02-10 11:09   ` Jeffy Chen
  0 siblings, 0 replies; 23+ messages in thread
From: Jeffy Chen @ 2018-02-10 11:09 UTC (permalink / raw)
  To: linux-arm-kernel

Add wakeup event action for Pen Insert gpio key, to avoid wakeup when
inserting the pen.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---

Changes in v2:
Specify wakeup event action instead of irq trigger type as Brian
suggested.

 arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts b/arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts
index 191a6bcb1704..ef2de0057c5c 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts
@@ -134,6 +134,8 @@
 		gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
 		linux,code = <SW_PEN_INSERTED>;
 		linux,input-type = <EV_SW>;
+		/* Wakeup only when ejecting */
+		wakeup-event-action = <EV_ACT_DEASSERTED>;
 		wakeup-source;
 	};
 };
-- 
2.11.0

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

* Re: [PATCH v2 1/3] Input: gpio-keys - add support for wakeup event action
  2018-02-10 11:09 ` [PATCH v2 1/3] Input: gpio-keys - add support for " Jeffy Chen
@ 2018-02-12 22:13   ` Brian Norris
  2018-02-13 10:40     ` Enric Balletbo i Serra
  2018-02-23 10:04     ` JeffyChen
  0 siblings, 2 replies; 23+ messages in thread
From: Brian Norris @ 2018-02-12 22:13 UTC (permalink / raw)
  To: Jeffy Chen
  Cc: linux-kernel, briannorris, dtor, dianders,
	Enric Balletbo i Serra, Thomas Gleixner, Joseph Lo, stephen lu,
	Dmitry Torokhov, Kate Stewart, linux-input, Greg Kroah-Hartman,
	Philippe Ombredanne, Arvind Yadav

Hi Jeffy,

On Sat, Feb 10, 2018 at 07:09:05PM +0800, Jeffy Chen wrote:
> Add support for specifying event actions to trigger wakeup when using
> the gpio-keys input device as a wakeup source.
> 
> This would allow the device to configure when to wakeup the system. For
> example a gpio-keys input device for pen insert, may only want to wakeup
> the system when ejecting the pen.
> 
> Suggested-by: Brian Norris <briannorris@chromium.org>
> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> ---
> 
> Changes in v2:
> Specify wakeup event action instead of irq trigger type as Brian
> suggested.
> 
>  drivers/input/keyboard/gpio_keys.c     | 27 +++++++++++++++++++++++++++
>  include/linux/gpio_keys.h              |  2 ++
>  include/uapi/linux/input-event-codes.h |  9 +++++++++
>  3 files changed, 38 insertions(+)
> 
> diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
> index 87e613dc33b8..5c57339d3999 100644
> --- a/drivers/input/keyboard/gpio_keys.c
> +++ b/drivers/input/keyboard/gpio_keys.c
> @@ -45,6 +45,8 @@ struct gpio_button_data {
>  	unsigned int software_debounce;	/* in msecs, for GPIO-driven buttons */
>  
>  	unsigned int irq;
> +	unsigned int irq_trigger_type;
> +	unsigned int wakeup_trigger_type;
>  	spinlock_t lock;
>  	bool disabled;
>  	bool key_pressed;
> @@ -540,6 +542,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
>  	}
>  
>  	if (bdata->gpiod) {
> +		int active_low = gpiod_is_active_low(bdata->gpiod);
> +
>  		if (button->debounce_interval) {
>  			error = gpiod_set_debounce(bdata->gpiod,
>  					button->debounce_interval * 1000);
> @@ -568,6 +572,16 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
>  		isr = gpio_keys_gpio_isr;
>  		irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
>  
> +		switch (button->wakeup_event_action) {
> +		case EV_ACT_ASSERTED:
> +			bdata->wakeup_trigger_type = active_low ?
> +				IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING;
> +			break;
> +		case EV_ACT_DEASSERTED:
> +			bdata->wakeup_trigger_type = active_low ?
> +				IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
> +			break;

What about EV_ACT_ANY? And default case? I think for ANY, we're OK
letting suspend/resume not reconfigure the trigger type, but maybe a
comment here to note that?

> +		}
>  	} else {

What about the 'else' case? Shouldn't we try to handle that?

Brian

>  		if (!button->irq) {
>  			dev_err(dev, "Found button without gpio or irq\n");
> @@ -618,6 +632,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
>  		return error;
>  	}
>  
> +	bdata->irq_trigger_type = irq_get_trigger_type(bdata->irq);
> +
>  	return 0;
>  }
>  
> @@ -718,6 +734,9 @@ gpio_keys_get_devtree_pdata(struct device *dev)
>  			/* legacy name */
>  			fwnode_property_read_bool(child, "gpio-key,wakeup");
>  
> +		fwnode_property_read_u32(child, "wakeup-event-action",
> +					 &button->wakeup_event_action);
> +
>  		button->can_disable =
>  			fwnode_property_read_bool(child, "linux,can-disable");
>  
> @@ -854,6 +873,10 @@ static int __maybe_unused gpio_keys_suspend(struct device *dev)
>  	if (device_may_wakeup(dev)) {
>  		for (i = 0; i < ddata->pdata->nbuttons; i++) {
>  			struct gpio_button_data *bdata = &ddata->data[i];
> +
> +			if (bdata->button->wakeup && bdata->wakeup_trigger_type)
> +				irq_set_irq_type(bdata->irq,
> +						 bdata->wakeup_trigger_type);
>  			if (bdata->button->wakeup)
>  				enable_irq_wake(bdata->irq);
>  			bdata->suspended = true;
> @@ -878,6 +901,10 @@ static int __maybe_unused gpio_keys_resume(struct device *dev)
>  	if (device_may_wakeup(dev)) {
>  		for (i = 0; i < ddata->pdata->nbuttons; i++) {
>  			struct gpio_button_data *bdata = &ddata->data[i];
> +
> +			if (bdata->button->wakeup && bdata->wakeup_trigger_type)
> +				irq_set_irq_type(bdata->irq,
> +						 bdata->irq_trigger_type);
>  			if (bdata->button->wakeup)
>  				disable_irq_wake(bdata->irq);
>  			bdata->suspended = false;
> diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h
> index d06bf77400f1..7160df54a6fe 100644
> --- a/include/linux/gpio_keys.h
> +++ b/include/linux/gpio_keys.h
> @@ -13,6 +13,7 @@ struct device;
>   * @desc:		label that will be attached to button's gpio
>   * @type:		input event type (%EV_KEY, %EV_SW, %EV_ABS)
>   * @wakeup:		configure the button as a wake-up source
> + * @wakeup_event_action:	event action to trigger wakeup
>   * @debounce_interval:	debounce ticks interval in msecs
>   * @can_disable:	%true indicates that userspace is allowed to
>   *			disable button via sysfs
> @@ -26,6 +27,7 @@ struct gpio_keys_button {
>  	const char *desc;
>  	unsigned int type;
>  	int wakeup;
> +	int wakeup_event_action;
>  	int debounce_interval;
>  	bool can_disable;
>  	int value;
> diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> index 53fbae27b280..d7917b0bd438 100644
> --- a/include/uapi/linux/input-event-codes.h
> +++ b/include/uapi/linux/input-event-codes.h
> @@ -32,6 +32,15 @@
>  #define INPUT_PROP_CNT			(INPUT_PROP_MAX + 1)
>  
>  /*
> + * Event action types
> + */
> +#define EV_ACT_ANY			0x00	/* asserted or deasserted */
> +#define EV_ACT_ASSERTED			0x01	/* asserted */
> +#define EV_ACT_DEASSERTED		0x02	/* deasserted */
> +#define EV_ACT_MAX			0x02
> +#define EV_ACT_CNT			(EV_ACT_MAX+1)
> +
> +/*
>   * Event types
>   */
>  
> -- 
> 2.11.0
> 
> 

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

* Re: [PATCH v2 1/3] Input: gpio-keys - add support for wakeup event action
  2018-02-12 22:13   ` Brian Norris
@ 2018-02-13 10:40     ` Enric Balletbo i Serra
  2018-02-13 18:25       ` Brian Norris
  2018-02-23 10:04     ` JeffyChen
  1 sibling, 1 reply; 23+ messages in thread
From: Enric Balletbo i Serra @ 2018-02-13 10:40 UTC (permalink / raw)
  To: Brian Norris, Jeffy Chen
  Cc: linux-kernel, briannorris, dtor, dianders, Thomas Gleixner,
	Joseph Lo, stephen lu, Dmitry Torokhov, Kate Stewart,
	linux-input, Greg Kroah-Hartman, Philippe Ombredanne,
	Arvind Yadav

Hi Jeffy,

On 12/02/18 23:13, Brian Norris wrote:
> Hi Jeffy,
> 
> On Sat, Feb 10, 2018 at 07:09:05PM +0800, Jeffy Chen wrote:
>> Add support for specifying event actions to trigger wakeup when using
>> the gpio-keys input device as a wakeup source.
>>
>> This would allow the device to configure when to wakeup the system. For
>> example a gpio-keys input device for pen insert, may only want to wakeup
>> the system when ejecting the pen.
>>
>> Suggested-by: Brian Norris <briannorris@chromium.org>
>> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
>> ---
>>
>> Changes in v2:
>> Specify wakeup event action instead of irq trigger type as Brian
>> suggested.
>>
>>  drivers/input/keyboard/gpio_keys.c     | 27 +++++++++++++++++++++++++++
>>  include/linux/gpio_keys.h              |  2 ++
>>  include/uapi/linux/input-event-codes.h |  9 +++++++++
>>  3 files changed, 38 insertions(+)
>>
>> diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
>> index 87e613dc33b8..5c57339d3999 100644
>> --- a/drivers/input/keyboard/gpio_keys.c
>> +++ b/drivers/input/keyboard/gpio_keys.c
>> @@ -45,6 +45,8 @@ struct gpio_button_data {
>>  	unsigned int software_debounce;	/* in msecs, for GPIO-driven buttons */
>>  
>>  	unsigned int irq;
>> +	unsigned int irq_trigger_type;
>> +	unsigned int wakeup_trigger_type;
>>  	spinlock_t lock;
>>  	bool disabled;
>>  	bool key_pressed;
>> @@ -540,6 +542,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
>>  	}
>>  
>>  	if (bdata->gpiod) {
>> +		int active_low = gpiod_is_active_low(bdata->gpiod);
>> +
>>  		if (button->debounce_interval) {
>>  			error = gpiod_set_debounce(bdata->gpiod,
>>  					button->debounce_interval * 1000);
>> @@ -568,6 +572,16 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
>>  		isr = gpio_keys_gpio_isr;
>>  		irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
>>  
>> +		switch (button->wakeup_event_action) {
>> +		case EV_ACT_ASSERTED:
>> +			bdata->wakeup_trigger_type = active_low ?
>> +				IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING;
>> +			break;
>> +		case EV_ACT_DEASSERTED:
>> +			bdata->wakeup_trigger_type = active_low ?
>> +				IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
>> +			break;
> 
> What about EV_ACT_ANY? And default case? I think for ANY, we're OK
> letting suspend/resume not reconfigure the trigger type, but maybe a
> comment here to note that?
> 
>> +		}
>>  	} else {
> 
> What about the 'else' case? Shouldn't we try to handle that?
> 
> Brian
> 
>>  		if (!button->irq) {
>>  			dev_err(dev, "Found button without gpio or irq\n");
>> @@ -618,6 +632,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
>>  		return error;
>>  	}
>>  
>> +	bdata->irq_trigger_type = irq_get_trigger_type(bdata->irq);
>> +
>>  	return 0;
>>  }
>>  
>> @@ -718,6 +734,9 @@ gpio_keys_get_devtree_pdata(struct device *dev)
>>  			/* legacy name */
>>  			fwnode_property_read_bool(child, "gpio-key,wakeup");
>>  
>> +		fwnode_property_read_u32(child, "wakeup-event-action",
>> +					 &button->wakeup_event_action);
>> +
>>  		button->can_disable =
>>  			fwnode_property_read_bool(child, "linux,can-disable");
>>  
>> @@ -854,6 +873,10 @@ static int __maybe_unused gpio_keys_suspend(struct device *dev)
>>  	if (device_may_wakeup(dev)) {
>>  		for (i = 0; i < ddata->pdata->nbuttons; i++) {
>>  			struct gpio_button_data *bdata = &ddata->data[i];
>> +
>> +			if (bdata->button->wakeup && bdata->wakeup_trigger_type)
>> +				irq_set_irq_type(bdata->irq,
>> +						 bdata->wakeup_trigger_type);
>>  			if (bdata->button->wakeup)
>>  				enable_irq_wake(bdata->irq);
>>  			bdata->suspended = true;
>> @@ -878,6 +901,10 @@ static int __maybe_unused gpio_keys_resume(struct device *dev)
>>  	if (device_may_wakeup(dev)) {
>>  		for (i = 0; i < ddata->pdata->nbuttons; i++) {
>>  			struct gpio_button_data *bdata = &ddata->data[i];
>> +
>> +			if (bdata->button->wakeup && bdata->wakeup_trigger_type)
>> +				irq_set_irq_type(bdata->irq,
>> +						 bdata->irq_trigger_type);
>>  			if (bdata->button->wakeup)
>>  				disable_irq_wake(bdata->irq);
>>  			bdata->suspended = false;
>> diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h
>> index d06bf77400f1..7160df54a6fe 100644
>> --- a/include/linux/gpio_keys.h
>> +++ b/include/linux/gpio_keys.h
>> @@ -13,6 +13,7 @@ struct device;
>>   * @desc:		label that will be attached to button's gpio
>>   * @type:		input event type (%EV_KEY, %EV_SW, %EV_ABS)
>>   * @wakeup:		configure the button as a wake-up source
>> + * @wakeup_event_action:	event action to trigger wakeup
>>   * @debounce_interval:	debounce ticks interval in msecs
>>   * @can_disable:	%true indicates that userspace is allowed to
>>   *			disable button via sysfs
>> @@ -26,6 +27,7 @@ struct gpio_keys_button {
>>  	const char *desc;
>>  	unsigned int type;
>>  	int wakeup;
>> +	int wakeup_event_action;
>>  	int debounce_interval;
>>  	bool can_disable;
>>  	int value;
>> diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
>> index 53fbae27b280..d7917b0bd438 100644
>> --- a/include/uapi/linux/input-event-codes.h
>> +++ b/include/uapi/linux/input-event-codes.h
>> @@ -32,6 +32,15 @@
>>  #define INPUT_PROP_CNT			(INPUT_PROP_MAX + 1)
>>  
>>  /*
>> + * Event action types
>> + */
>> +#define EV_ACT_ANY			0x00	/* asserted or deasserted */
>> +#define EV_ACT_ASSERTED			0x01	/* asserted */
>> +#define EV_ACT_DEASSERTED		0x02	/* deasserted */
>> +#define EV_ACT_MAX			0x02
>> +#define EV_ACT_CNT			(EV_ACT_MAX+1)
>> +
>> +/*
>>   * Event types
>>   */
>>  
>> -- 
>> 2.11.0
>>
>>

Not sure if you were aware but there is also some discussion related to this,
maybe we can join the efforts?

v1: https://patchwork.kernel.org/patch/10208261/
v2: https://patchwork.kernel.org/patch/10211147/

Best regards,
 Enric

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

* Re: [PATCH v2 1/3] Input: gpio-keys - add support for wakeup event action
  2018-02-13 10:40     ` Enric Balletbo i Serra
@ 2018-02-13 18:25       ` Brian Norris
  2018-02-13 22:25         ` Enric Balletbo Serra
  0 siblings, 1 reply; 23+ messages in thread
From: Brian Norris @ 2018-02-13 18:25 UTC (permalink / raw)
  To: Enric Balletbo i Serra
  Cc: Jeffy Chen, linux-kernel, briannorris, dtor, dianders,
	Thomas Gleixner, Joseph Lo, stephen lu, Dmitry Torokhov,
	Kate Stewart, linux-input, Greg Kroah-Hartman,
	Philippe Ombredanne, Arvind Yadav

Hi Enric,

On Tue, Feb 13, 2018 at 11:40:44AM +0100, Enric Balletbo i Serra wrote:
> On 12/02/18 23:13, Brian Norris wrote:
> > On Sat, Feb 10, 2018 at 07:09:05PM +0800, Jeffy Chen wrote:
> >> Add support for specifying event actions to trigger wakeup when using
> >> the gpio-keys input device as a wakeup source.
> >>
> >> This would allow the device to configure when to wakeup the system. For
> >> example a gpio-keys input device for pen insert, may only want to wakeup
> >> the system when ejecting the pen.
> >>
> >> Suggested-by: Brian Norris <briannorris@chromium.org>
> >> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> >> ---
> >>
> >> Changes in v2:
> >> Specify wakeup event action instead of irq trigger type as Brian
> >> suggested.
[...]
> Not sure if you were aware but there is also some discussion related to this,
> maybe we can join the efforts?
> 
> v1: https://patchwork.kernel.org/patch/10208261/
> v2: https://patchwork.kernel.org/patch/10211147/

Thanks for the pointers. IIUC, that's talking about a different problem:
how to utilize a GPIO key in level-triggered mode. That touches similar
code, but it doesn't really have anything to do with configuring a
different wakeup trigger type.

The two patches would need to be reconciled, if they both are going to
be merged. But otherwise, I think they're perfectly fine to be separate.

Brian

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

* Re: [PATCH v2 1/3] Input: gpio-keys - add support for wakeup event action
  2018-02-13 18:25       ` Brian Norris
@ 2018-02-13 22:25         ` Enric Balletbo Serra
  2018-02-23 10:15           ` JeffyChen
  0 siblings, 1 reply; 23+ messages in thread
From: Enric Balletbo Serra @ 2018-02-13 22:25 UTC (permalink / raw)
  To: Brian Norris
  Cc: Enric Balletbo i Serra, Jeffy Chen, linux-kernel, Brian Norris,
	dtor, Doug Anderson, Thomas Gleixner, Joseph Lo, stephen lu,
	Dmitry Torokhov, Kate Stewart, linux-input, Greg Kroah-Hartman,
	Philippe Ombredanne, Arvind Yadav

Hi,

2018-02-13 19:25 GMT+01:00 Brian Norris <briannorris@chromium.org>:
> Hi Enric,
>
> On Tue, Feb 13, 2018 at 11:40:44AM +0100, Enric Balletbo i Serra wrote:
>> On 12/02/18 23:13, Brian Norris wrote:
>> > On Sat, Feb 10, 2018 at 07:09:05PM +0800, Jeffy Chen wrote:
>> >> Add support for specifying event actions to trigger wakeup when using
>> >> the gpio-keys input device as a wakeup source.
>> >>
>> >> This would allow the device to configure when to wakeup the system. For
>> >> example a gpio-keys input device for pen insert, may only want to wakeup
>> >> the system when ejecting the pen.
>> >>
>> >> Suggested-by: Brian Norris <briannorris@chromium.org>
>> >> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
>> >> ---
>> >>
>> >> Changes in v2:
>> >> Specify wakeup event action instead of irq trigger type as Brian
>> >> suggested.
> [...]
>> Not sure if you were aware but there is also some discussion related to this,
>> maybe we can join the efforts?
>>
>> v1: https://patchwork.kernel.org/patch/10208261/
>> v2: https://patchwork.kernel.org/patch/10211147/
>
> Thanks for the pointers. IIUC, that's talking about a different problem:
> how to utilize a GPIO key in level-triggered mode. That touches similar
> code, but it doesn't really have anything to do with configuring a
> different wakeup trigger type.
>

Right, sorry. I see now what you are doing.

> The two patches would need to be reconciled, if they both are going to
> be merged. But otherwise, I think they're perfectly fine to be separate.
>

Yes, that's why I got confused, I had those patches applied on my tree
and when I tried to apply these failed and I wrongly assumed that were
doing the same. Waiting to test the third version ;)

Thanks,
 Enric

> Brian

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

* Re: [PATCH v2 0/3] gpio-keys: Add support for specifying wakeup event action
@ 2018-02-14 13:39   ` Heiko Stübner
  0 siblings, 0 replies; 23+ messages in thread
From: Heiko Stübner @ 2018-02-14 13:39 UTC (permalink / raw)
  To: Jeffy Chen
  Cc: linux-kernel, briannorris, dtor, dianders, Arnd Bergmann,
	Joseph Lo, Rob Herring, Catalin Marinas, Emil Renner Berthing,
	Enric Balletbo i Serra, Brian Norris, Thomas Gleixner,
	Philippe Ombredanne, linux-rockchip, Kate Stewart, linux-input,
	Will Deacon, Matthias Kaehlcke, devicetree, stephen lu,
	Greg Kroah-Hartman, Arvind Yadav, linux-arm-kernel,
	Dmitry Torokhov, Mark Rutland

Hi Jeffy,

Am Samstag, 10. Februar 2018, 12:09:04 CET schrieb Jeffy Chen:
> On chromebook kevin, we are using gpio-keys for pen insert event. But
> we only want it to wakeup the system when ejecting the pen.
> 
> So we may need to change the interrupt trigger type during suspending.
> 
> Changes in v2:
> Specify wakeup event action instead of irq trigger type as Brian
> suggested.
> 
> Jeffy Chen (3):
>   Input: gpio-keys - add support for wakeup event action
>   Input: gpio-keys - allow setting wakeup event action in DT
>   arm64: dts: rockchip: Avoid wakeup when inserting the pen

The recipient-selection for the mail thread seems to be a bit off and
I only got the cover-letter and patch 3/3.
Therefore I won't really see if and when the Input-changes get
accepted. So please ping me once that has happened so I can pick up
the rockchip dts change for it.


Thanks
Heiko

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

* Re: [PATCH v2 0/3] gpio-keys: Add support for specifying wakeup event action
@ 2018-02-14 13:39   ` Heiko Stübner
  0 siblings, 0 replies; 23+ messages in thread
From: Heiko Stübner @ 2018-02-14 13:39 UTC (permalink / raw)
  To: Jeffy Chen
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	briannorris-hpIqsD4AKlfQT0dZR+AlfA, dtor-hpIqsD4AKlfQT0dZR+AlfA,
	dianders-hpIqsD4AKlfQT0dZR+AlfA, Arnd Bergmann, Joseph Lo,
	Rob Herring, Catalin Marinas, Emil Renner Berthing,
	Enric Balletbo i Serra, Brian Norris, Thomas Gleixner,
	Philippe Ombredanne,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Kate Stewart,
	linux-input-u79uwXL29TY76Z2rM5mHXA, Will Deacon,
	Matthias Kaehlcke, devicetree-u79uwXL29TY76Z2rM5mHXA, stephen lu,
	Greg Kroah-Hartman, Arvind Yadav

Hi Jeffy,

Am Samstag, 10. Februar 2018, 12:09:04 CET schrieb Jeffy Chen:
> On chromebook kevin, we are using gpio-keys for pen insert event. But
> we only want it to wakeup the system when ejecting the pen.
> 
> So we may need to change the interrupt trigger type during suspending.
> 
> Changes in v2:
> Specify wakeup event action instead of irq trigger type as Brian
> suggested.
> 
> Jeffy Chen (3):
>   Input: gpio-keys - add support for wakeup event action
>   Input: gpio-keys - allow setting wakeup event action in DT
>   arm64: dts: rockchip: Avoid wakeup when inserting the pen

The recipient-selection for the mail thread seems to be a bit off and
I only got the cover-letter and patch 3/3.
Therefore I won't really see if and when the Input-changes get
accepted. So please ping me once that has happened so I can pick up
the rockchip dts change for it.


Thanks
Heiko
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2 0/3] gpio-keys: Add support for specifying wakeup event action
@ 2018-02-14 13:39   ` Heiko Stübner
  0 siblings, 0 replies; 23+ messages in thread
From: Heiko Stübner @ 2018-02-14 13:39 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Jeffy,

Am Samstag, 10. Februar 2018, 12:09:04 CET schrieb Jeffy Chen:
> On chromebook kevin, we are using gpio-keys for pen insert event. But
> we only want it to wakeup the system when ejecting the pen.
> 
> So we may need to change the interrupt trigger type during suspending.
> 
> Changes in v2:
> Specify wakeup event action instead of irq trigger type as Brian
> suggested.
> 
> Jeffy Chen (3):
>   Input: gpio-keys - add support for wakeup event action
>   Input: gpio-keys - allow setting wakeup event action in DT
>   arm64: dts: rockchip: Avoid wakeup when inserting the pen

The recipient-selection for the mail thread seems to be a bit off and
I only got the cover-letter and patch 3/3.
Therefore I won't really see if and when the Input-changes get
accepted. So please ping me once that has happened so I can pick up
the rockchip dts change for it.


Thanks
Heiko

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

* Re: [PATCH v2 0/3] gpio-keys: Add support for specifying wakeup event action
  2018-02-14 13:39   ` Heiko Stübner
  (?)
@ 2018-02-23  9:43     ` JeffyChen
  -1 siblings, 0 replies; 23+ messages in thread
From: JeffyChen @ 2018-02-23  9:43 UTC (permalink / raw)
  To: Heiko Stübner
  Cc: linux-kernel, briannorris, dtor, dianders, Arnd Bergmann,
	Joseph Lo, Rob Herring, Catalin Marinas, Emil Renner Berthing,
	Enric Balletbo i Serra, Brian Norris, Thomas Gleixner,
	Philippe Ombredanne, linux-rockchip, Kate Stewart, linux-input,
	Will Deacon, Matthias Kaehlcke, devicetree, stephen lu,
	Greg Kroah-Hartman, Arvind Yadav, linux-arm-kernel,
	Dmitry Torokhov, Mark Rutland

Hi Heiko,

Thanks for your reply :)

On 02/14/2018 09:39 PM, Heiko Stübner wrote:
> Hi Jeffy,
>
> Am Samstag, 10. Februar 2018, 12:09:04 CET schrieb Jeffy Chen:
>> On chromebook kevin, we are using gpio-keys for pen insert event. But
>> we only want it to wakeup the system when ejecting the pen.
>>
>> So we may need to change the interrupt trigger type during suspending.
>>
>> Changes in v2:
>> Specify wakeup event action instead of irq trigger type as Brian
>> suggested.
>>
>> Jeffy Chen (3):
>>    Input: gpio-keys - add support for wakeup event action
>>    Input: gpio-keys - allow setting wakeup event action in DT
>>    arm64: dts: rockchip: Avoid wakeup when inserting the pen
>
> The recipient-selection for the mail thread seems to be a bit off and
> I only got the cover-letter and patch 3/3.
> Therefore I won't really see if and when the Input-changes get
> accepted. So please ping me once that has happened so I can pick up
> the rockchip dts change for it.
oops, sorry, i'll add you to the CC list in the next version :)

>
>
> Thanks
> Heiko
>
>
>

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

* Re: [PATCH v2 0/3] gpio-keys: Add support for specifying wakeup event action
@ 2018-02-23  9:43     ` JeffyChen
  0 siblings, 0 replies; 23+ messages in thread
From: JeffyChen @ 2018-02-23  9:43 UTC (permalink / raw)
  To: Heiko Stübner
  Cc: Kate Stewart, Mark Rutland, Emil Renner Berthing, stephen lu,
	Catalin Marinas, Will Deacon, Joseph Lo, Brian Norris,
	linux-rockchip, Matthias Kaehlcke, linux-input, Arvind Yadav,
	dtor, devicetree, Arnd Bergmann, dianders, Rob Herring,
	briannorris, Thomas Gleixner, linux-arm-kernel,
	Greg Kroah-Hartman, Dmitry Torokhov, linux-kernel,
	Philippe Ombredanne, Enric Balletbo i Serra

Hi Heiko,

Thanks for your reply :)

On 02/14/2018 09:39 PM, Heiko Stübner wrote:
> Hi Jeffy,
>
> Am Samstag, 10. Februar 2018, 12:09:04 CET schrieb Jeffy Chen:
>> On chromebook kevin, we are using gpio-keys for pen insert event. But
>> we only want it to wakeup the system when ejecting the pen.
>>
>> So we may need to change the interrupt trigger type during suspending.
>>
>> Changes in v2:
>> Specify wakeup event action instead of irq trigger type as Brian
>> suggested.
>>
>> Jeffy Chen (3):
>>    Input: gpio-keys - add support for wakeup event action
>>    Input: gpio-keys - allow setting wakeup event action in DT
>>    arm64: dts: rockchip: Avoid wakeup when inserting the pen
>
> The recipient-selection for the mail thread seems to be a bit off and
> I only got the cover-letter and patch 3/3.
> Therefore I won't really see if and when the Input-changes get
> accepted. So please ping me once that has happened so I can pick up
> the rockchip dts change for it.
oops, sorry, i'll add you to the CC list in the next version :)

>
>
> Thanks
> Heiko
>
>
>



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v2 0/3] gpio-keys: Add support for specifying wakeup event action
@ 2018-02-23  9:43     ` JeffyChen
  0 siblings, 0 replies; 23+ messages in thread
From: JeffyChen @ 2018-02-23  9:43 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Heiko,

Thanks for your reply :)

On 02/14/2018 09:39 PM, Heiko St?bner wrote:
> Hi Jeffy,
>
> Am Samstag, 10. Februar 2018, 12:09:04 CET schrieb Jeffy Chen:
>> On chromebook kevin, we are using gpio-keys for pen insert event. But
>> we only want it to wakeup the system when ejecting the pen.
>>
>> So we may need to change the interrupt trigger type during suspending.
>>
>> Changes in v2:
>> Specify wakeup event action instead of irq trigger type as Brian
>> suggested.
>>
>> Jeffy Chen (3):
>>    Input: gpio-keys - add support for wakeup event action
>>    Input: gpio-keys - allow setting wakeup event action in DT
>>    arm64: dts: rockchip: Avoid wakeup when inserting the pen
>
> The recipient-selection for the mail thread seems to be a bit off and
> I only got the cover-letter and patch 3/3.
> Therefore I won't really see if and when the Input-changes get
> accepted. So please ping me once that has happened so I can pick up
> the rockchip dts change for it.
oops, sorry, i'll add you to the CC list in the next version :)

>
>
> Thanks
> Heiko
>
>
>

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

* Re: [PATCH v2 1/3] Input: gpio-keys - add support for wakeup event action
  2018-02-12 22:13   ` Brian Norris
  2018-02-13 10:40     ` Enric Balletbo i Serra
@ 2018-02-23 10:04     ` JeffyChen
  2018-03-02  2:32       ` Brian Norris
  1 sibling, 1 reply; 23+ messages in thread
From: JeffyChen @ 2018-02-23 10:04 UTC (permalink / raw)
  To: Brian Norris
  Cc: linux-kernel, briannorris, dtor, dianders,
	Enric Balletbo i Serra, Thomas Gleixner, Joseph Lo, stephen lu,
	Dmitry Torokhov, Kate Stewart, linux-input, Greg Kroah-Hartman,
	Philippe Ombredanne, Arvind Yadav

Hi Brian,

Thanks for your reply.

On 02/13/2018 06:13 AM, Brian Norris wrote:
>> >
>> >  	if (bdata->gpiod) {
>> >+		int active_low = gpiod_is_active_low(bdata->gpiod);
>> >+
>> >  		if (button->debounce_interval) {
>> >  			error = gpiod_set_debounce(bdata->gpiod,
>> >  					button->debounce_interval * 1000);
>> >@@ -568,6 +572,16 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
>> >  		isr = gpio_keys_gpio_isr;
>> >  		irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
>> >
>> >+		switch (button->wakeup_event_action) {
>> >+		case EV_ACT_ASSERTED:
>> >+			bdata->wakeup_trigger_type = active_low ?
>> >+				IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING;
>> >+			break;
>> >+		case EV_ACT_DEASSERTED:
>> >+			bdata->wakeup_trigger_type = active_low ?
>> >+				IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
>> >+			break;
> What about EV_ACT_ANY? And default case? I think for ANY, we're OK
> letting suspend/resume not reconfigure the trigger type, but maybe a
> comment here to note that?
right, will add comment in the next version.
>
>> >+		}
>> >  	} else {
> What about the 'else' case? Shouldn't we try to handle that?
i think the else case is for irq key, which would generate down and up 
events in one irq, so it would use the same trigger type for all these 3 
cases.

i'll add comment in the next version too.
>
> Brian
>

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

* Re: [PATCH v2 1/3] Input: gpio-keys - add support for wakeup event action
  2018-02-13 22:25         ` Enric Balletbo Serra
@ 2018-02-23 10:15           ` JeffyChen
  0 siblings, 0 replies; 23+ messages in thread
From: JeffyChen @ 2018-02-23 10:15 UTC (permalink / raw)
  To: Enric Balletbo Serra, Brian Norris
  Cc: Enric Balletbo i Serra, linux-kernel, Brian Norris, dtor,
	Doug Anderson, Thomas Gleixner, Joseph Lo, stephen lu,
	Dmitry Torokhov, Kate Stewart, linux-input, Greg Kroah-Hartman,
	Philippe Ombredanne, Arvind Yadav

Hi Enric,

Thanks for your reply.

On 02/14/2018 06:25 AM, Enric Balletbo Serra wrote:
> Hi,
>
> 2018-02-13 19:25 GMT+01:00 Brian Norris <briannorris@chromium.org>:
>> Hi Enric,
>>
>> On Tue, Feb 13, 2018 at 11:40:44AM +0100, Enric Balletbo i Serra wrote:
>>> On 12/02/18 23:13, Brian Norris wrote:
>>>> On Sat, Feb 10, 2018 at 07:09:05PM +0800, Jeffy Chen wrote:
>>>>> Add support for specifying event actions to trigger wakeup when using
>>>>> the gpio-keys input device as a wakeup source.
>>>>>
>>>>> This would allow the device to configure when to wakeup the system. For
>>>>> example a gpio-keys input device for pen insert, may only want to wakeup
>>>>> the system when ejecting the pen.
>>>>>
>>>>> Suggested-by: Brian Norris <briannorris@chromium.org>
>>>>> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
>>>>> ---
>>>>>
>>>>> Changes in v2:
>>>>> Specify wakeup event action instead of irq trigger type as Brian
>>>>> suggested.
>> [...]
>>> Not sure if you were aware but there is also some discussion related to this,
>>> maybe we can join the efforts?
>>>
>>> v1: https://patchwork.kernel.org/patch/10208261/
>>> v2: https://patchwork.kernel.org/patch/10211147/
>>
>> Thanks for the pointers. IIUC, that's talking about a different problem:
>> how to utilize a GPIO key in level-triggered mode. That touches similar
>> code, but it doesn't really have anything to do with configuring a
>> different wakeup trigger type.
>>
>
> Right, sorry. I see now what you are doing.
>
>> The two patches would need to be reconciled, if they both are going to
>> be merged. But otherwise, I think they're perfectly fine to be separate.
>>
>
> Yes, that's why I got confused, I had those patches applied on my tree
> and when I tried to apply these failed and I wrongly assumed that were
> doing the same. Waiting to test the third version ;)
right, they are not related, and i should add the level irq case after 
that series merged :)

>
> Thanks,
>   Enric
>
>> Brian
>
>
>

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

* Re: [PATCH v2 2/3] Input: gpio-keys - allow setting wakeup event action in DT
  2018-02-10 11:09 ` [PATCH v2 2/3] Input: gpio-keys - allow setting wakeup event action in DT Jeffy Chen
@ 2018-03-01 21:26   ` Rob Herring
  0 siblings, 0 replies; 23+ messages in thread
From: Rob Herring @ 2018-03-01 21:26 UTC (permalink / raw)
  To: Jeffy Chen
  Cc: linux-kernel, briannorris, dtor, dianders, devicetree,
	Dmitry Torokhov, linux-input, Mark Rutland

On Sat, Feb 10, 2018 at 07:09:06PM +0800, Jeffy Chen wrote:
> Allow specifying event actions to trigger wakeup when using the
> gpio-keys input device as a wakeup source.
> 
> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> ---
> 
> Changes in v2:
> Specify wakeup event action instead of irq trigger type as Brian
> suggested.
> 
>  Documentation/devicetree/bindings/input/gpio-keys.txt | 8 ++++++++
>  1 file changed, 8 insertions(+)

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

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

* Re: [PATCH v2 1/3] Input: gpio-keys - add support for wakeup event action
  2018-02-23 10:04     ` JeffyChen
@ 2018-03-02  2:32       ` Brian Norris
  2018-03-02  3:57         ` JeffyChen
  0 siblings, 1 reply; 23+ messages in thread
From: Brian Norris @ 2018-03-02  2:32 UTC (permalink / raw)
  To: JeffyChen
  Cc: linux-kernel, briannorris, dtor, dianders,
	Enric Balletbo i Serra, Thomas Gleixner, Joseph Lo, stephen lu,
	Dmitry Torokhov, Kate Stewart, linux-input, Greg Kroah-Hartman,
	Philippe Ombredanne, Arvind Yadav

Hi,

On Fri, Feb 23, 2018 at 06:04:22PM +0800, Jeffy Chen wrote:
> On 02/13/2018 06:13 AM, Brian Norris wrote:
> > > >
> > > >  	if (bdata->gpiod) {
> > > >+		int active_low = gpiod_is_active_low(bdata->gpiod);
> > > >+
> > > >  		if (button->debounce_interval) {
> > > >  			error = gpiod_set_debounce(bdata->gpiod,
> > > >  					button->debounce_interval * 1000);
> > > >@@ -568,6 +572,16 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
> > > >  		isr = gpio_keys_gpio_isr;
> > > >  		irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
> > > >
> > > >+		switch (button->wakeup_event_action) {
> > > >+		case EV_ACT_ASSERTED:
> > > >+			bdata->wakeup_trigger_type = active_low ?
> > > >+				IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING;
> > > >+			break;
> > > >+		case EV_ACT_DEASSERTED:
> > > >+			bdata->wakeup_trigger_type = active_low ?
> > > >+				IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
> > > >+			break;
> > What about EV_ACT_ANY? And default case? I think for ANY, we're OK
> > letting suspend/resume not reconfigure the trigger type, but maybe a
> > comment here to note that?
> right, will add comment in the next version.
> > 
> > > >+		}
> > > >  	} else {
> > What about the 'else' case? Shouldn't we try to handle that?
> i think the else case is for irq key, which would generate down and up
> events in one irq, so it would use the same trigger type for all these 3
> cases.

Not necessarily. It uses whatever trigger was provided in
platform/DT/etc. data. You could retrieve that with
irq_get_trigger_type() and try to interpret that. Or you could just
outlaw using that combination (e.g., in the binding documentation).

Brian

> i'll add comment in the next version too.
> > 
> > Brian
> > 
> 
> 

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

* Re: [PATCH v2 1/3] Input: gpio-keys - add support for wakeup event action
  2018-03-02  2:32       ` Brian Norris
@ 2018-03-02  3:57         ` JeffyChen
  0 siblings, 0 replies; 23+ messages in thread
From: JeffyChen @ 2018-03-02  3:57 UTC (permalink / raw)
  To: Brian Norris
  Cc: linux-kernel, briannorris, dtor, dianders,
	Enric Balletbo i Serra, Thomas Gleixner, Joseph Lo, stephen lu,
	Dmitry Torokhov, Kate Stewart, linux-input, Greg Kroah-Hartman,
	Philippe Ombredanne, Arvind Yadav

Hi Brain,

Thanks for your reply.

On 03/02/2018 10:32 AM, Brian Norris wrote:
>>> > >What about the 'else' case? Shouldn't we try to handle that?
>> >i think the else case is for irq key, which would generate down and up
>> >events in one irq, so it would use the same trigger type for all these 3
>> >cases.
> Not necessarily. It uses whatever trigger was provided in
> platform/DT/etc. data. You could retrieve that with
> irq_get_trigger_type() and try to interpret that. Or you could just
> outlaw using that combination (e.g., in the binding documentation).
i think for the IRQ button case the assert/deassert/any are using the 
same irq trigger type, so it should be ok to leave the wakeup trigger 
type to be 0(not reconfigure the trigger type)...

i've made a v3 to add a comment about that, but forgot to send it :(

>
> Brian
>

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

end of thread, other threads:[~2018-03-02  3:57 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-10 11:09 [PATCH v2 0/3] gpio-keys: Add support for specifying wakeup event action Jeffy Chen
2018-02-10 11:09 ` Jeffy Chen
2018-02-10 11:09 ` Jeffy Chen
2018-02-10 11:09 ` [PATCH v2 1/3] Input: gpio-keys - add support for " Jeffy Chen
2018-02-12 22:13   ` Brian Norris
2018-02-13 10:40     ` Enric Balletbo i Serra
2018-02-13 18:25       ` Brian Norris
2018-02-13 22:25         ` Enric Balletbo Serra
2018-02-23 10:15           ` JeffyChen
2018-02-23 10:04     ` JeffyChen
2018-03-02  2:32       ` Brian Norris
2018-03-02  3:57         ` JeffyChen
2018-02-10 11:09 ` [PATCH v2 2/3] Input: gpio-keys - allow setting wakeup event action in DT Jeffy Chen
2018-03-01 21:26   ` Rob Herring
2018-02-10 11:09 ` [PATCH v2 3/3] arm64: dts: rockchip: Avoid wakeup when inserting the pen Jeffy Chen
2018-02-10 11:09   ` Jeffy Chen
2018-02-10 11:09   ` Jeffy Chen
2018-02-14 13:39 ` [PATCH v2 0/3] gpio-keys: Add support for specifying wakeup event action Heiko Stübner
2018-02-14 13:39   ` Heiko Stübner
2018-02-14 13:39   ` Heiko Stübner
2018-02-23  9:43   ` JeffyChen
2018-02-23  9:43     ` JeffyChen
2018-02-23  9:43     ` JeffyChen

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.