All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Input: elan_i2c - do not clobber interrupt trigger on x86
@ 2017-09-28 17:09 Dmitry Torokhov
  2017-10-10  3:50 ` Dmitry Torokhov
  2017-10-10 15:00 ` Aaron Durbin
  0 siblings, 2 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2017-09-28 17:09 UTC (permalink / raw)
  To: linux-input
  Cc: KT Liao, Guenter Roeck, Aaron Durbin, Craig Bergstrom, linux-kernel

On x86 we historically used falling edge interrupts in the driver
because that's how first Chrome devices were configured. They also
did not use ACPI to enumerate I2C devices (because back then there
was no kernel support for that), so trigger was hard-coded in the
driver. However the controller behavior is much more reliable if
we use level triggers, and that is how we configured ARM devices,
and how want to configure newer x86 devices as well. All newer
x86 boxes have their I2C devices enumerated in ACPI.

Let's see if platform code (ACPI, DT) described interrupt and
specified particular trigger type, and if so, let's use it instead
of always clobbering trigger with IRQF_TRIGGER_FALLING. We will
still use this trigger type as a fallback if platform code left
interrupt trigger unconfigured.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196761
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/mouse/elan_i2c_core.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
index a2d2077303cb..c33f2cce6ba9 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -26,6 +26,7 @@
 #include <linux/init.h>
 #include <linux/input/mt.h>
 #include <linux/interrupt.h>
+#include <linux/irq.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/kernel.h>
@@ -1141,10 +1142,13 @@ static int elan_probe(struct i2c_client *client,
 		return error;
 
 	/*
-	 * Systems using device tree should set up interrupt via DTS,
-	 * the rest will use the default falling edge interrupts.
+	 * Platform code (ACPI, DTS) should normally set up interrupt
+	 * for us, but in case it did not let's fall back to using falling
+	 * edge to be compatible with older Chromebooks.
 	 */
-	irqflags = dev->of_node ? 0 : IRQF_TRIGGER_FALLING;
+	irqflags = irq_get_trigger_type(client->irq);
+	if (!irqflags)
+		irqflags = IRQF_TRIGGER_FALLING;
 
 	error = devm_request_threaded_irq(dev, client->irq, NULL, elan_isr,
 					  irqflags | IRQF_ONESHOT,
-- 
2.14.2.822.g60be5d43e6-goog


-- 
Dmitry

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

* Re: [PATCH] Input: elan_i2c - do not clobber interrupt trigger on x86
  2017-09-28 17:09 [PATCH] Input: elan_i2c - do not clobber interrupt trigger on x86 Dmitry Torokhov
@ 2017-10-10  3:50 ` Dmitry Torokhov
  2017-10-10 15:00 ` Aaron Durbin
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2017-10-10  3:50 UTC (permalink / raw)
  To: linux-input; +Cc: KT Liao, Guenter Roeck, Aaron Durbin, Craig Bergstrom

On Thu, Sep 28, 2017 at 10:09:02AM -0700, Dmitry Torokhov wrote:
> On x86 we historically used falling edge interrupts in the driver
> because that's how first Chrome devices were configured. They also
> did not use ACPI to enumerate I2C devices (because back then there
> was no kernel support for that), so trigger was hard-coded in the
> driver. However the controller behavior is much more reliable if
> we use level triggers, and that is how we configured ARM devices,
> and how want to configure newer x86 devices as well. All newer
> x86 boxes have their I2C devices enumerated in ACPI.
> 
> Let's see if platform code (ACPI, DT) described interrupt and
> specified particular trigger type, and if so, let's use it instead
> of always clobbering trigger with IRQF_TRIGGER_FALLING. We will
> still use this trigger type as a fallback if platform code left
> interrupt trigger unconfigured.
> 
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196761
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Guys, can get some revewed-bys please so I do not appear merging too
much code unilaterally ;) ?

> ---
>  drivers/input/mouse/elan_i2c_core.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
> index a2d2077303cb..c33f2cce6ba9 100644
> --- a/drivers/input/mouse/elan_i2c_core.c
> +++ b/drivers/input/mouse/elan_i2c_core.c
> @@ -26,6 +26,7 @@
>  #include <linux/init.h>
>  #include <linux/input/mt.h>
>  #include <linux/interrupt.h>
> +#include <linux/irq.h>
>  #include <linux/module.h>
>  #include <linux/slab.h>
>  #include <linux/kernel.h>
> @@ -1141,10 +1142,13 @@ static int elan_probe(struct i2c_client *client,
>  		return error;
>  
>  	/*
> -	 * Systems using device tree should set up interrupt via DTS,
> -	 * the rest will use the default falling edge interrupts.
> +	 * Platform code (ACPI, DTS) should normally set up interrupt
> +	 * for us, but in case it did not let's fall back to using falling
> +	 * edge to be compatible with older Chromebooks.
>  	 */
> -	irqflags = dev->of_node ? 0 : IRQF_TRIGGER_FALLING;
> +	irqflags = irq_get_trigger_type(client->irq);
> +	if (!irqflags)
> +		irqflags = IRQF_TRIGGER_FALLING;
>  
>  	error = devm_request_threaded_irq(dev, client->irq, NULL, elan_isr,
>  					  irqflags | IRQF_ONESHOT,
> -- 
> 2.14.2.822.g60be5d43e6-goog
> 
> 
> -- 
> Dmitry

-- 
Dmitry

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

* Re: [PATCH] Input: elan_i2c - do not clobber interrupt trigger on x86
  2017-09-28 17:09 [PATCH] Input: elan_i2c - do not clobber interrupt trigger on x86 Dmitry Torokhov
  2017-10-10  3:50 ` Dmitry Torokhov
@ 2017-10-10 15:00 ` Aaron Durbin
  1 sibling, 0 replies; 3+ messages in thread
From: Aaron Durbin @ 2017-10-10 15:00 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, KT Liao, Guenter Roeck, Craig Bergstrom,
	Linux Kernel Mailing List

On Thu, Sep 28, 2017 at 11:09 AM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On x86 we historically used falling edge interrupts in the driver
> because that's how first Chrome devices were configured. They also
> did not use ACPI to enumerate I2C devices (because back then there
> was no kernel support for that), so trigger was hard-coded in the
> driver. However the controller behavior is much more reliable if
> we use level triggers, and that is how we configured ARM devices,
> and how want to configure newer x86 devices as well. All newer
> x86 boxes have their I2C devices enumerated in ACPI.
>
> Let's see if platform code (ACPI, DT) described interrupt and
> specified particular trigger type, and if so, let's use it instead
> of always clobbering trigger with IRQF_TRIGGER_FALLING. We will
> still use this trigger type as a fallback if platform code left
> interrupt trigger unconfigured.
>
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196761
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/input/mouse/elan_i2c_core.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
> index a2d2077303cb..c33f2cce6ba9 100644
> --- a/drivers/input/mouse/elan_i2c_core.c
> +++ b/drivers/input/mouse/elan_i2c_core.c
> @@ -26,6 +26,7 @@
>  #include <linux/init.h>
>  #include <linux/input/mt.h>
>  #include <linux/interrupt.h>
> +#include <linux/irq.h>
>  #include <linux/module.h>
>  #include <linux/slab.h>
>  #include <linux/kernel.h>
> @@ -1141,10 +1142,13 @@ static int elan_probe(struct i2c_client *client,
>                 return error;
>
>         /*
> -        * Systems using device tree should set up interrupt via DTS,
> -        * the rest will use the default falling edge interrupts.
> +        * Platform code (ACPI, DTS) should normally set up interrupt
> +        * for us, but in case it did not let's fall back to using falling
> +        * edge to be compatible with older Chromebooks.
>          */
> -       irqflags = dev->of_node ? 0 : IRQF_TRIGGER_FALLING;
> +       irqflags = irq_get_trigger_type(client->irq);
> +       if (!irqflags)
> +               irqflags = IRQF_TRIGGER_FALLING;
>
>         error = devm_request_threaded_irq(dev, client->irq, NULL, elan_isr,
>                                           irqflags | IRQF_ONESHOT,
> --
> 2.14.2.822.g60be5d43e6-goog

Reviewed-by: Aaron Durbin <adurbin@chromium.org>

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

end of thread, other threads:[~2017-10-10 15:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-28 17:09 [PATCH] Input: elan_i2c - do not clobber interrupt trigger on x86 Dmitry Torokhov
2017-10-10  3:50 ` Dmitry Torokhov
2017-10-10 15:00 ` Aaron Durbin

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.