* [RFC 1/1] Input: gpio_keys - add device tree support for interrupt only keys
@ 2014-09-30 15:40 Alexander Stein
2014-10-14 6:30 ` Alexander Stein
0 siblings, 1 reply; 3+ messages in thread
From: Alexander Stein @ 2014-09-30 15:40 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: Alexander Stein, linux-input
This features already exists for board config setups. Add support for
device tree based systems.
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
---
I'm aware thatthe device tree binding description is missing yet. But for now
I just want some feedback about that approach.
drivers/input/keyboard/gpio_keys.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 8c98e97..7b90e1b 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -29,6 +29,7 @@
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/of_gpio.h>
+#include <linux/of_irq.h>
#include <linux/spinlock.h>
struct gpio_button_data {
@@ -617,28 +618,32 @@ gpio_keys_get_devtree_pdata(struct device *dev)
i = 0;
for_each_child_of_node(node, pp) {
- int gpio;
+ int gpio = -1;
+ int irq;
enum of_gpio_flags flags;
- if (!of_find_property(pp, "gpios", NULL)) {
+ irq = irq_of_parse_and_map(pp, 0);
+
+ if (of_find_property(pp, "gpios", NULL)) {
+ gpio = of_get_gpio_flags(pp, 0, &flags);
+ if (gpio < 0) {
+ error = gpio;
+ if (error != -EPROBE_DEFER)
+ dev_err(dev,
+ "Failed to get gpio flags, error: %d\n",
+ error);
+ return ERR_PTR(error);
+ }
+ } else if (irq == 0) {
pdata->nbuttons--;
- dev_warn(dev, "Found button without gpios\n");
+ dev_warn(dev, "Found button without gpios or irqs\n");
continue;
}
- gpio = of_get_gpio_flags(pp, 0, &flags);
- if (gpio < 0) {
- error = gpio;
- if (error != -EPROBE_DEFER)
- dev_err(dev,
- "Failed to get gpio flags, error: %d\n",
- error);
- return ERR_PTR(error);
- }
-
button = &pdata->buttons[i++];
button->gpio = gpio;
+ button->irq = irq;
button->active_low = flags & OF_GPIO_ACTIVE_LOW;
if (of_property_read_u32(pp, "linux,code", &button->code)) {
--
1.8.5.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC 1/1] Input: gpio_keys - add device tree support for interrupt only keys
2014-09-30 15:40 [RFC 1/1] Input: gpio_keys - add device tree support for interrupt only keys Alexander Stein
@ 2014-10-14 6:30 ` Alexander Stein
2014-11-04 7:50 ` Dmitry Torokhov
0 siblings, 1 reply; 3+ messages in thread
From: Alexander Stein @ 2014-10-14 6:30 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input
Ping?
On Tuesday 30 September 2014 17:40:47, Alexander Stein wrote:
> This features already exists for board config setups. Add support for
> device tree based systems.
>
> Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
> ---
> I'm aware thatthe device tree binding description is missing yet. But for now
> I just want some feedback about that approach.
>
> drivers/input/keyboard/gpio_keys.c | 31 ++++++++++++++++++-------------
> 1 file changed, 18 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
> index 8c98e97..7b90e1b 100644
> --- a/drivers/input/keyboard/gpio_keys.c
> +++ b/drivers/input/keyboard/gpio_keys.c
> @@ -29,6 +29,7 @@
> #include <linux/of.h>
> #include <linux/of_platform.h>
> #include <linux/of_gpio.h>
> +#include <linux/of_irq.h>
> #include <linux/spinlock.h>
>
> struct gpio_button_data {
> @@ -617,28 +618,32 @@ gpio_keys_get_devtree_pdata(struct device *dev)
>
> i = 0;
> for_each_child_of_node(node, pp) {
> - int gpio;
> + int gpio = -1;
> + int irq;
> enum of_gpio_flags flags;
>
> - if (!of_find_property(pp, "gpios", NULL)) {
> + irq = irq_of_parse_and_map(pp, 0);
> +
> + if (of_find_property(pp, "gpios", NULL)) {
> + gpio = of_get_gpio_flags(pp, 0, &flags);
> + if (gpio < 0) {
> + error = gpio;
> + if (error != -EPROBE_DEFER)
> + dev_err(dev,
> + "Failed to get gpio flags, error: %d\n",
> + error);
> + return ERR_PTR(error);
> + }
> + } else if (irq == 0) {
> pdata->nbuttons--;
> - dev_warn(dev, "Found button without gpios\n");
> + dev_warn(dev, "Found button without gpios or irqs\n");
> continue;
> }
>
> - gpio = of_get_gpio_flags(pp, 0, &flags);
> - if (gpio < 0) {
> - error = gpio;
> - if (error != -EPROBE_DEFER)
> - dev_err(dev,
> - "Failed to get gpio flags, error: %d\n",
> - error);
> - return ERR_PTR(error);
> - }
> -
> button = &pdata->buttons[i++];
>
> button->gpio = gpio;
> + button->irq = irq;
> button->active_low = flags & OF_GPIO_ACTIVE_LOW;
>
> if (of_property_read_u32(pp, "linux,code", &button->code)) {
>
--
Dipl.-Inf. Alexander Stein
SYS TEC electronic GmbH
Am Windrad 2
08468 Heinsdorfergrund
Tel.: 03765 38600-1156
Fax: 03765 38600-4100
Email: alexander.stein@systec-electronic.com
Website: www.systec-electronic.com
Managing Director: Dipl.-Phys. Siegmar Schmidt
Commercial registry: Amtsgericht Chemnitz, HRB 28082
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC 1/1] Input: gpio_keys - add device tree support for interrupt only keys
2014-10-14 6:30 ` Alexander Stein
@ 2014-11-04 7:50 ` Dmitry Torokhov
0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2014-11-04 7:50 UTC (permalink / raw)
To: Alexander Stein; +Cc: linux-input
Hi ALexander,
On Tue, Oct 14, 2014 at 08:30:43AM +0200, Alexander Stein wrote:
> Ping?
>
> On Tuesday 30 September 2014 17:40:47, Alexander Stein wrote:
> > This features already exists for board config setups. Add support for
> > device tree based systems.
> >
> > Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
> > ---
> > I'm aware thatthe device tree binding description is missing yet. But for now
> > I just want some feedback about that approach.
> >
> > drivers/input/keyboard/gpio_keys.c | 31 ++++++++++++++++++-------------
> > 1 file changed, 18 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
> > index 8c98e97..7b90e1b 100644
> > --- a/drivers/input/keyboard/gpio_keys.c
> > +++ b/drivers/input/keyboard/gpio_keys.c
> > @@ -29,6 +29,7 @@
> > #include <linux/of.h>
> > #include <linux/of_platform.h>
> > #include <linux/of_gpio.h>
> > +#include <linux/of_irq.h>
> > #include <linux/spinlock.h>
> >
> > struct gpio_button_data {
> > @@ -617,28 +618,32 @@ gpio_keys_get_devtree_pdata(struct device *dev)
> >
> > i = 0;
> > for_each_child_of_node(node, pp) {
> > - int gpio;
> > + int gpio = -1;
> > + int irq;
> > enum of_gpio_flags flags;
> >
> > - if (!of_find_property(pp, "gpios", NULL)) {
> > + irq = irq_of_parse_and_map(pp, 0);
> > +
Hmm, the current button setup code will ignore the irq if button's gpio
is valid. We shoudl either not try to parse/map irq or make that code
properly handle cases where both gpio and interrupt are specified (and
they might be different).
Also, board code supports having a single interrupt shared between all
buttons, it woudl be nice if OF supported the same.
And lastly, we need the device tree binding updated (please CC device
tree folks/list).
Thanks!
> > + if (of_find_property(pp, "gpios", NULL)) {
> > + gpio = of_get_gpio_flags(pp, 0, &flags);
> > + if (gpio < 0) {
> > + error = gpio;
> > + if (error != -EPROBE_DEFER)
> > + dev_err(dev,
> > + "Failed to get gpio flags, error: %d\n",
> > + error);
> > + return ERR_PTR(error);
> > + }
> > + } else if (irq == 0) {
> > pdata->nbuttons--;
> > - dev_warn(dev, "Found button without gpios\n");
> > + dev_warn(dev, "Found button without gpios or irqs\n");
> > continue;
> > }
> >
> > - gpio = of_get_gpio_flags(pp, 0, &flags);
> > - if (gpio < 0) {
> > - error = gpio;
> > - if (error != -EPROBE_DEFER)
> > - dev_err(dev,
> > - "Failed to get gpio flags, error: %d\n",
> > - error);
> > - return ERR_PTR(error);
> > - }
> > -
> > button = &pdata->buttons[i++];
> >
> > button->gpio = gpio;
> > + button->irq = irq;
> > button->active_low = flags & OF_GPIO_ACTIVE_LOW;
> >
> > if (of_property_read_u32(pp, "linux,code", &button->code)) {
> >
>
--
Dmitry
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-04 7:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-30 15:40 [RFC 1/1] Input: gpio_keys - add device tree support for interrupt only keys Alexander Stein
2014-10-14 6:30 ` Alexander Stein
2014-11-04 7:50 ` Dmitry Torokhov
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).