lkml.org 
[lkml]   [2018]   [Feb]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/3] Input: gpio-keys - add support for wakeup interrupt trigger type
Date
Add support for specifying a different interrupt trigger type for 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>
---

drivers/input/keyboard/gpio_keys.c | 20 ++++++++++++++++++--
include/linux/gpio_keys.h | 2 ++
2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 87e613dc33b8..5e5c93b75a71 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -45,6 +45,7 @@ struct gpio_button_data {
unsigned int software_debounce; /* in msecs, for GPIO-driven buttons */

unsigned int irq;
+ unsigned int irq_trigger_type;
spinlock_t lock;
bool disabled;
bool key_pressed;
@@ -618,6 +619,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 +721,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-trigger-type",
+ &button->wakeup_trigger_type);
+
button->can_disable =
fwnode_property_read_bool(child, "linux,can-disable");

@@ -854,7 +860,12 @@ 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)
+ const struct gpio_keys_button *button = bdata->button;
+
+ if (button->wakeup && button->wakeup_trigger_type)
+ irq_set_irq_type(bdata->irq,
+ button->wakeup_trigger_type);
+ if (button->wakeup)
enable_irq_wake(bdata->irq);
bdata->suspended = true;
}
@@ -878,7 +889,12 @@ 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)
+ const struct gpio_keys_button *button = bdata->button;
+
+ if (button->wakeup && button->wakeup_trigger_type)
+ irq_set_irq_type(bdata->irq,
+ bdata->irq_trigger_type);
+ if (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..9b7e7137f768 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_trigger_type: wakeup interrupt trigger type
* @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_trigger_type;
int debounce_interval;
bool can_disable;
int value;
--
2.11.0

\
 
 \ /
  Last update: 2018-02-09 12:56    [W:0.120 / U:3.512 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site