devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] gpio-keys: Add support for specifying wakeup interrupt trigger type
@ 2018-02-09 11:55 Jeffy Chen
  2018-02-09 11:55 ` [PATCH 2/3] Input: gpio-keys - allow setting wakeup interrupt trigger type in DT Jeffy Chen
  2018-02-09 11:55 ` [PATCH 3/3] arm64: dts: rockchip: Avoid wakeup when inserting the pen Jeffy Chen
  0 siblings, 2 replies; 7+ messages in thread
From: Jeffy Chen @ 2018-02-09 11:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: briannorris, dtor, dianders, Jeffy Chen, Guenter Roeck,
	Arnd Bergmann, Joseph Lo, Rob Herring, Catalin Marinas,
	Emil Renner Berthing, 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.


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

 .../devicetree/bindings/input/gpio-keys.txt          |  9 +++++++++
 arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts    |  2 ++
 drivers/input/keyboard/gpio_keys.c                   | 20 ++++++++++++++++++--
 include/linux/gpio_keys.h                            |  2 ++
 4 files changed, 31 insertions(+), 2 deletions(-)

-- 
2.11.0

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

* [PATCH 2/3] Input: gpio-keys - allow setting wakeup interrupt trigger type in DT
  2018-02-09 11:55 [PATCH 0/3] gpio-keys: Add support for specifying wakeup interrupt trigger type Jeffy Chen
@ 2018-02-09 11:55 ` Jeffy Chen
  2018-02-09 23:42   ` Brian Norris
  2018-02-09 11:55 ` [PATCH 3/3] arm64: dts: rockchip: Avoid wakeup when inserting the pen Jeffy Chen
  1 sibling, 1 reply; 7+ messages in thread
From: Jeffy Chen @ 2018-02-09 11:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: briannorris, dtor, dianders, Jeffy Chen, devicetree, Rob Herring,
	Dmitry Torokhov, linux-input, Mark Rutland

Allow specifying a different interrupt trigger type for wakeup when
using the gpio-keys input device as a wakeup source.

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

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

diff --git a/Documentation/devicetree/bindings/input/gpio-keys.txt b/Documentation/devicetree/bindings/input/gpio-keys.txt
index a94940481e55..61926cef708f 100644
--- a/Documentation/devicetree/bindings/input/gpio-keys.txt
+++ b/Documentation/devicetree/bindings/input/gpio-keys.txt
@@ -26,6 +26,15 @@ 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-trigger-type: Specifies the interrupt trigger type for wakeup.
+		 The value is defined in <dt-bindings/interrupt-controller/irq.h>
+		 Only the following flags are supported:
+			IRQ_TYPE_NONE
+			IRQ_TYPE_EDGE_RISING
+			IRQ_TYPE_EDGE_FALLING
+			IRQ_TYPE_EDGE_BOTH
+			IRQ_TYPE_LEVEL_HIGH
+			IRQ_TYPE_LEVEL_LOW
 	- 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] 7+ messages in thread

* [PATCH 3/3] arm64: dts: rockchip: Avoid wakeup when inserting the pen
  2018-02-09 11:55 [PATCH 0/3] gpio-keys: Add support for specifying wakeup interrupt trigger type Jeffy Chen
  2018-02-09 11:55 ` [PATCH 2/3] Input: gpio-keys - allow setting wakeup interrupt trigger type in DT Jeffy Chen
@ 2018-02-09 11:55 ` Jeffy Chen
  1 sibling, 0 replies; 7+ messages in thread
From: Jeffy Chen @ 2018-02-09 11:55 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 interrupt trigger type for Pen Insert gpio key, to avoid
wakeup when inserting the pen.

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

 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..5edfbd288b2f 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-trigger-type = <IRQ_TYPE_EDGE_RISING>;
 		wakeup-source;
 	};
 };
-- 
2.11.0

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

* Re: [PATCH 2/3] Input: gpio-keys - allow setting wakeup interrupt trigger type in DT
  2018-02-09 11:55 ` [PATCH 2/3] Input: gpio-keys - allow setting wakeup interrupt trigger type in DT Jeffy Chen
@ 2018-02-09 23:42   ` Brian Norris
       [not found]     ` <20180209234246.GA252335-1WoqFLEneaORBCj4nEdE8WJtCfot02Oa@public.gmane.org>
  2018-02-18 23:34     ` Rob Herring
  0 siblings, 2 replies; 7+ messages in thread
From: Brian Norris @ 2018-02-09 23:42 UTC (permalink / raw)
  To: Jeffy Chen
  Cc: linux-kernel, briannorris, dtor, dianders, devicetree,
	Rob Herring, Dmitry Torokhov, linux-input, Mark Rutland

Hi Jeffy,

On Fri, Feb 09, 2018 at 07:55:09PM +0800, Jeffy Chen wrote:
> Allow specifying a different interrupt trigger type for wakeup when
> using the gpio-keys input device as a wakeup source.
> 
> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> ---
> 
>  Documentation/devicetree/bindings/input/gpio-keys.txt | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/input/gpio-keys.txt b/Documentation/devicetree/bindings/input/gpio-keys.txt
> index a94940481e55..61926cef708f 100644
> --- a/Documentation/devicetree/bindings/input/gpio-keys.txt
> +++ b/Documentation/devicetree/bindings/input/gpio-keys.txt
> @@ -26,6 +26,15 @@ 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-trigger-type: Specifies the interrupt trigger type for wakeup.
> +		 The value is defined in <dt-bindings/interrupt-controller/irq.h>

Do you really want to codify interrupt triggers here? It seems like most
of the information about edge vs. level is already codified elsewhere,
so this becomes a little redundant. And in fact, some bindings may be
specifying a "gpio", not technically an interrupt (at least not
directly), so it feels weird to apply IRQ_* flags to them right here.
Anyway, I think he only piece you really want to describe here is, do we
wake on "event asserted", "event deasserted", or both. (The "none" case
would just mean you shouldn't have the "wakeup-source" property.)

So maybe:

	wakeup-trigger-type: 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:
	  1: asserted
	  2: deasserted
	  3: both asserted and deasserted

? We could still make macros out of those, if we want
(input/linux-event-codes.h?). And then leave it up to the driver to
determine how to translate that into the appropriate edge or level
triggers.

Brian

> +		 Only the following flags are supported:
> +			IRQ_TYPE_NONE
> +			IRQ_TYPE_EDGE_RISING
> +			IRQ_TYPE_EDGE_FALLING
> +			IRQ_TYPE_EDGE_BOTH
> +			IRQ_TYPE_LEVEL_HIGH
> +			IRQ_TYPE_LEVEL_LOW
>  	- 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	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/3] Input: gpio-keys - allow setting wakeup interrupt trigger type in DT
       [not found]     ` <20180209234246.GA252335-1WoqFLEneaORBCj4nEdE8WJtCfot02Oa@public.gmane.org>
@ 2018-02-10  0:06       ` JeffyChen
  0 siblings, 0 replies; 7+ messages in thread
From: JeffyChen @ 2018-02-10  0:06 UTC (permalink / raw)
  To: Brian Norris
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	briannorris-hpIqsD4AKlfQT0dZR+AlfA, dtor-hpIqsD4AKlfQT0dZR+AlfA,
	dianders-hpIqsD4AKlfQT0dZR+AlfA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Dmitry Torokhov,
	linux-input-u79uwXL29TY76Z2rM5mHXA, Mark Rutland

Hi Brian,

Thanks for your reply.

On 02/10/2018 07:42 AM, Brian Norris wrote:
> Hi Jeffy,
>
> On Fri, Feb 09, 2018 at 07:55:09PM +0800, Jeffy Chen wrote:
>> Allow specifying a different interrupt trigger type for wakeup when
>> using the gpio-keys input device as a wakeup source.
>>
>> Signed-off-by: Jeffy Chen <jeffy.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
>> ---
>>
>>   Documentation/devicetree/bindings/input/gpio-keys.txt | 9 +++++++++
>>   1 file changed, 9 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/input/gpio-keys.txt b/Documentation/devicetree/bindings/input/gpio-keys.txt
>> index a94940481e55..61926cef708f 100644
>> --- a/Documentation/devicetree/bindings/input/gpio-keys.txt
>> +++ b/Documentation/devicetree/bindings/input/gpio-keys.txt
>> @@ -26,6 +26,15 @@ 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-trigger-type: Specifies the interrupt trigger type for wakeup.
>> +		 The value is defined in <dt-bindings/interrupt-controller/irq.h>
>
> Do you really want to codify interrupt triggers here? It seems like most
> of the information about edge vs. level is already codified elsewhere,
> so this becomes a little redundant. And in fact, some bindings may be
> specifying a "gpio", not technically an interrupt (at least not
> directly), so it feels weird to apply IRQ_* flags to them right here.
> Anyway, I think he only piece you really want to describe here is, do we
> wake on "event asserted", "event deasserted", or both. (The "none" case
> would just mean you shouldn't have the "wakeup-source" property.)
>
> So maybe:
>
> 	wakeup-trigger-type: 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:
> 	  1: asserted
> 	  2: deasserted
> 	  3: both asserted and deasserted
>
> ? We could still make macros out of those, if we want
> (input/linux-event-codes.h?). And then leave it up to the driver to
> determine how to translate that into the appropriate edge or level
> triggers.
make sense, will do it in the next version.
>
> Brian
>
>> +		 Only the following flags are supported:
>> +			IRQ_TYPE_NONE
>> +			IRQ_TYPE_EDGE_RISING
>> +			IRQ_TYPE_EDGE_FALLING
>> +			IRQ_TYPE_EDGE_BOTH
>> +			IRQ_TYPE_LEVEL_HIGH
>> +			IRQ_TYPE_LEVEL_LOW
>>   	- 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
>>
>>
>
>
>


--
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] 7+ messages in thread

* Re: [PATCH 2/3] Input: gpio-keys - allow setting wakeup interrupt trigger type in DT
  2018-02-09 23:42   ` Brian Norris
       [not found]     ` <20180209234246.GA252335-1WoqFLEneaORBCj4nEdE8WJtCfot02Oa@public.gmane.org>
@ 2018-02-18 23:34     ` Rob Herring
  2018-02-21  5:38       ` Brian Norris
  1 sibling, 1 reply; 7+ messages in thread
From: Rob Herring @ 2018-02-18 23:34 UTC (permalink / raw)
  To: Brian Norris
  Cc: Jeffy Chen, linux-kernel, briannorris, dtor, dianders,
	devicetree, Dmitry Torokhov, linux-input, Mark Rutland

On Fri, Feb 09, 2018 at 03:42:47PM -0800, Brian Norris wrote:
> Hi Jeffy,
> 
> On Fri, Feb 09, 2018 at 07:55:09PM +0800, Jeffy Chen wrote:
> > Allow specifying a different interrupt trigger type for wakeup when
> > using the gpio-keys input device as a wakeup source.
> > 
> > Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> > ---
> > 
> >  Documentation/devicetree/bindings/input/gpio-keys.txt | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/input/gpio-keys.txt b/Documentation/devicetree/bindings/input/gpio-keys.txt
> > index a94940481e55..61926cef708f 100644
> > --- a/Documentation/devicetree/bindings/input/gpio-keys.txt
> > +++ b/Documentation/devicetree/bindings/input/gpio-keys.txt
> > @@ -26,6 +26,15 @@ 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-trigger-type: Specifies the interrupt trigger type for wakeup.
> > +		 The value is defined in <dt-bindings/interrupt-controller/irq.h>
> 
> Do you really want to codify interrupt triggers here? It seems like most
> of the information about edge vs. level is already codified elsewhere,
> so this becomes a little redundant. And in fact, some bindings may be
> specifying a "gpio", not technically an interrupt (at least not
> directly), so it feels weird to apply IRQ_* flags to them right here.
> Anyway, I think he only piece you really want to describe here is, do we
> wake on "event asserted", "event deasserted", or both. (The "none" case
> would just mean you shouldn't have the "wakeup-source" property.)
> 
> So maybe:
> 
> 	wakeup-trigger-type: 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:
> 	  1: asserted

As wakeup is an IRQ, that's assumed.

> 	  2: deasserted

Just invert the flags for the IRQ.

> 	  3: both asserted and deasserted

I don't see what would be the usecase. But wouldn't this be any edge 
(because level certainly doesn't make sense)?

> 
> ? We could still make macros out of those, if we want
> (input/linux-event-codes.h?). And then leave it up to the driver to
> determine how to translate that into the appropriate edge or level
> triggers.
> 
> Brian
> 
> > +		 Only the following flags are supported:
> > +			IRQ_TYPE_NONE
> > +			IRQ_TYPE_EDGE_RISING
> > +			IRQ_TYPE_EDGE_FALLING
> > +			IRQ_TYPE_EDGE_BOTH
> > +			IRQ_TYPE_LEVEL_HIGH
> > +			IRQ_TYPE_LEVEL_LOW
> >  	- 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	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/3] Input: gpio-keys - allow setting wakeup interrupt trigger type in DT
  2018-02-18 23:34     ` Rob Herring
@ 2018-02-21  5:38       ` Brian Norris
  0 siblings, 0 replies; 7+ messages in thread
From: Brian Norris @ 2018-02-21  5:38 UTC (permalink / raw)
  To: Rob Herring
  Cc: Jeffy Chen, linux-kernel, briannorris, dtor, dianders,
	devicetree, Dmitry Torokhov, linux-input, Mark Rutland

Hi,

On Sun, Feb 18, 2018 at 05:34:53PM -0600, Rob Herring wrote:
> On Fri, Feb 09, 2018 at 03:42:47PM -0800, Brian Norris wrote:
> > On Fri, Feb 09, 2018 at 07:55:09PM +0800, Jeffy Chen wrote:
> > > Allow specifying a different interrupt trigger type for wakeup when
> > > using the gpio-keys input device as a wakeup source.
> > > 
> > > Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> > > ---
> > > 
> > >  Documentation/devicetree/bindings/input/gpio-keys.txt | 9 +++++++++
> > >  1 file changed, 9 insertions(+)
> > > 
> > > diff --git a/Documentation/devicetree/bindings/input/gpio-keys.txt b/Documentation/devicetree/bindings/input/gpio-keys.txt
> > > index a94940481e55..61926cef708f 100644
> > > --- a/Documentation/devicetree/bindings/input/gpio-keys.txt
> > > +++ b/Documentation/devicetree/bindings/input/gpio-keys.txt
> > > @@ -26,6 +26,15 @@ 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-trigger-type: Specifies the interrupt trigger type for wakeup.
> > > +		 The value is defined in <dt-bindings/interrupt-controller/irq.h>
> > 
> > Do you really want to codify interrupt triggers here? It seems like most
> > of the information about edge vs. level is already codified elsewhere,
> > so this becomes a little redundant. And in fact, some bindings may be
> > specifying a "gpio", not technically an interrupt (at least not
> > directly), so it feels weird to apply IRQ_* flags to them right here.
> > Anyway, I think he only piece you really want to describe here is, do we
> > wake on "event asserted", "event deasserted", or both. (The "none" case
> > would just mean you shouldn't have the "wakeup-source" property.)
> > 
> > So maybe:
> > 
> > 	wakeup-trigger-type: 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:
> > 	  1: asserted
> 
> As wakeup is an IRQ, that's assumed.
> 
> > 	  2: deasserted
> 
> Just invert the flags for the IRQ.

What? Wouldn't that change the meaning of the key?

> > 	  3: both asserted and deasserted
> 
> I don't see what would be the usecase. But wouldn't this be any edge 
> (because level certainly doesn't make sense)?

Well, #3 is how the driver happens to currently interpret the binding ;)
I believe the idea is that you get wakeup triggers on all events
(pressed or released). I'm not actually sure why though, since it
doesn't really make for a good use case. (We want both edges in S0, but
not really in S3.)

For some background: the case that inspired this is SW_PEN_INSERTED. We
want to receive events on both edges (PEN_INSERTED = "asserted"; and
!PEN_INSERTED = "deasserted", meaning pen ejected) in S0 (e.g., to
show/hide special UI menus when we think the pen is "in use"). But in
S3, we tend to want to wake only when the pen is ejected. We can't
invert the IRQ, because then ejection and insertion get swapped...
Also, per the above, the current wakeup condition is for both edges. We
want to override that.

Brian

> > 
> > ? We could still make macros out of those, if we want
> > (input/linux-event-codes.h?). And then leave it up to the driver to
> > determine how to translate that into the appropriate edge or level
> > triggers.
> > 
> > Brian
> > 
> > > +		 Only the following flags are supported:
> > > +			IRQ_TYPE_NONE
> > > +			IRQ_TYPE_EDGE_RISING
> > > +			IRQ_TYPE_EDGE_FALLING
> > > +			IRQ_TYPE_EDGE_BOTH
> > > +			IRQ_TYPE_LEVEL_HIGH
> > > +			IRQ_TYPE_LEVEL_LOW
> > >  	- 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	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-02-21  5:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-09 11:55 [PATCH 0/3] gpio-keys: Add support for specifying wakeup interrupt trigger type Jeffy Chen
2018-02-09 11:55 ` [PATCH 2/3] Input: gpio-keys - allow setting wakeup interrupt trigger type in DT Jeffy Chen
2018-02-09 23:42   ` Brian Norris
     [not found]     ` <20180209234246.GA252335-1WoqFLEneaORBCj4nEdE8WJtCfot02Oa@public.gmane.org>
2018-02-10  0:06       ` JeffyChen
2018-02-18 23:34     ` Rob Herring
2018-02-21  5:38       ` Brian Norris
2018-02-09 11:55 ` [PATCH 3/3] arm64: dts: rockchip: Avoid wakeup when inserting the pen Jeffy Chen

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