All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] input: keyboard: gpio-keys: Try to parse IRQ from device tree
@ 2012-10-03 11:20 Tomasz Figa
       [not found] ` <1349263201-422-1-git-send-email-t.figa-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Tomasz Figa @ 2012-10-03 11:20 UTC (permalink / raw)
  To: linux-input
  Cc: devicetree-discuss, linux-samsung-soc, kyungmin.park,
	m.szyprowski, t.figa, tomasz.figa, dmitry.torokhov

On modern platforms using device tree and non-legacy IRQ domains there
is usually no way to perform direct translation between GPIO and IRQ,
because the IRQ of interest is not mapped yet into sparse IRQ namespace.

This patch modifies the gpio_keys driver to parse IRQ from device tree
and use gpio_to_irq only as a fallback.

Signed-off-by: Tomasz Figa <t.figa@samsung.com>
---
 Documentation/devicetree/bindings/gpio/gpio_keys.txt | 2 ++
 drivers/input/keyboard/gpio_keys.c                   | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/gpio/gpio_keys.txt b/Documentation/devicetree/bindings/gpio/gpio_keys.txt
index 5c2c021..7f318a5 100644
--- a/Documentation/devicetree/bindings/gpio/gpio_keys.txt
+++ b/Documentation/devicetree/bindings/gpio/gpio_keys.txt
@@ -20,6 +20,8 @@ Optional subnode-properties:
 	- debounce-interval: Debouncing interval time in milliseconds.
 	  If not specified defaults to 5.
 	- gpio-key,wakeup: Boolean, button can wake-up the system.
+	- interrupt: Interrupt used for this key (required if no translation
+	  between GPIO and IRQ is available).
 
 Example nodes:
 
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 6a68041..a33660c 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -28,6 +28,7 @@
 #include <linux/gpio.h>
 #include <linux/of_platform.h>
 #include <linux/of_gpio.h>
+#include <linux/of_irq.h>
 #include <linux/spinlock.h>
 
 struct gpio_button_data {
@@ -464,7 +465,7 @@ static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
 						button->debounce_interval;
 		}
 
-		irq = gpio_to_irq(button->gpio);
+		irq = (button->irq) ? : gpio_to_irq(button->gpio);
 		if (irq < 0) {
 			error = irq;
 			dev_err(dev,
@@ -597,6 +598,7 @@ gpio_keys_get_devtree_pdata(struct device *dev)
 
 		button = &pdata->buttons[i++];
 
+		button->irq = irq_of_parse_and_map(pp, 0);
 		button->gpio = of_get_gpio_flags(pp, 0, &flags);
 		button->active_low = flags & OF_GPIO_ACTIVE_LOW;
 
-- 
1.7.12

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

* Re: [PATCH] input: keyboard: gpio-keys: Try to parse IRQ from device tree
       [not found] ` <1349263201-422-1-git-send-email-t.figa-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2012-10-05  6:23   ` Dmitry Torokhov
  2012-10-05  7:59     ` Tomasz Figa
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2012-10-05  6:23 UTC (permalink / raw)
  To: Tomasz Figa
  Cc: linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	tomasz.figa-Re5JQEeQqe8AvxtiuMwx3w,
	kyungmin.park-Sze3O3UU22JBDgjK7y7TUQ,
	linux-input-u79uwXL29TY76Z2rM5mHXA,
	m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ

Hi Tomasz,

On Wed, Oct 03, 2012 at 01:20:00PM +0200, Tomasz Figa wrote:
> On modern platforms using device tree and non-legacy IRQ domains there
> is usually no way to perform direct translation between GPIO and IRQ,
> because the IRQ of interest is not mapped yet into sparse IRQ namespace.
> 
> This patch modifies the gpio_keys driver to parse IRQ from device tree
> and use gpio_to_irq only as a fallback.

This means that this change would need to be applied to every driver
that currently maps gpio to IRQ. Why can't gpio_to_irq() be fixed
instead?

Thanks.

-- 
Dmitry

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

* Re: [PATCH] input: keyboard: gpio-keys: Try to parse IRQ from device tree
  2012-10-05  6:23   ` Dmitry Torokhov
@ 2012-10-05  7:59     ` Tomasz Figa
  0 siblings, 0 replies; 3+ messages in thread
From: Tomasz Figa @ 2012-10-05  7:59 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, devicetree-discuss, linux-samsung-soc,
	kyungmin.park, m.szyprowski, tomasz.figa

Hi Dmitry,

On Thursday 04 of October 2012 23:23:15 Dmitry Torokhov wrote:
> Hi Tomasz,
> 
> On Wed, Oct 03, 2012 at 01:20:00PM +0200, Tomasz Figa wrote:
> > On modern platforms using device tree and non-legacy IRQ domains there
> > is usually no way to perform direct translation between GPIO and IRQ,
> > because the IRQ of interest is not mapped yet into sparse IRQ
> > namespace.
> > 
> > This patch modifies the gpio_keys driver to parse IRQ from device tree
> > and use gpio_to_irq only as a fallback.
> 
> This means that this change would need to be applied to every driver
> that currently maps gpio to IRQ. Why can't gpio_to_irq() be fixed
> instead?
> 

Now when I think of it again, there is a possibility of creating an IRQ 
mapping in .to_irq callback of GPIO chip, if it does not exist yet. This 
should be a better solution indeed. I will send a patch for pinctrl-samsung 
driver adding it.

Please disregard this patch.

Best regards,
-- 
Tomasz Figa
Samsung Poland R&D Center

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

end of thread, other threads:[~2012-10-05  7:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-03 11:20 [PATCH] input: keyboard: gpio-keys: Try to parse IRQ from device tree Tomasz Figa
     [not found] ` <1349263201-422-1-git-send-email-t.figa-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-10-05  6:23   ` Dmitry Torokhov
2012-10-05  7:59     ` Tomasz Figa

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.