diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-04-05 13:21:57 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-04-05 13:21:57 -0700 |
commit | 5414ab31b1e8dec34800201cb5211abf3436129e (patch) | |
tree | 1abb330d904362742b1eb88e62b1e95e60a83f71 /drivers/input/keyboard | |
parent | 672a9c106966f8d418478830975288b8096bb058 (diff) | |
parent | 664b0bae0b87f69bc9deb098f5e0158b9cf18e04 (diff) | |
download | linux-5414ab31b1e8dec34800201cb5211abf3436129e.tar.bz2 |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull input updates from Dmitry Torokhov:
- new driver for PhoenixRC Flight Controller Adapter
- new driver for RAVE SP Power button
- fixes for autosuspend-related deadlocks in a few unput USB dirvers
- support for 2nd wheel in ATech PS/2 mouse
- fix for ALPS trackpoint detection on Thinkpad L570 and Latitude 7370
- bunch of cleanups in various in PS/2 protocols
- other assorted changes and fixes
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (35 commits)
Input: i8042 - enable MUX on Sony VAIO VGN-CS series to fix touchpad
Input: stmfts, s6sy761 - update my e-mail
Input: stmfts - use async probe & suspend/resume to avoid 2s delay
Input: ALPS - fix TrackStick detection on Thinkpad L570 and Latitude 7370
Input: xpad - add PDP device id 0x02a4
Input: alps - report pressure of v3 and v7 trackstick
Input: pxrc - new driver for PhoenixRC Flight Controller Adapter
Input: usbtouchscreen - do not rely on input_dev->users
Input: usbtouchscreen - fix deadlock in autosuspend
Input: pegasus_notetaker - do not rely on input_dev->users
Input: pagasus_notetaker - fix deadlock in autosuspend
Input: synaptics_usb - do not rely on input_dev->users
Input: synaptics_usb - fix deadlock in autosuspend
Input: gpio-keys - add support for wakeup event action
Input: appletouch - use true and false for boolean values
Input: silead - add Chuwi Hi8 support
Input: analog - use get_cycles() on PPC
Input: stmpe-keypad - remove VLA usage
Input: i8042 - add Lenovo ThinkPad L460 to i8042 reset list
Input: add RAVE SP Powerbutton driver
...
Diffstat (limited to 'drivers/input/keyboard')
-rw-r--r-- | drivers/input/keyboard/gpio_keys.c | 145 | ||||
-rw-r--r-- | drivers/input/keyboard/stmpe-keypad.c | 16 |
2 files changed, 143 insertions, 18 deletions
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 87e613dc33b8..052e37675086 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -30,6 +30,7 @@ #include <linux/of.h> #include <linux/of_irq.h> #include <linux/spinlock.h> +#include <dt-bindings/input/gpio-keys.h> struct gpio_button_data { const struct gpio_keys_button *button; @@ -45,6 +46,7 @@ struct gpio_button_data { unsigned int software_debounce; /* in msecs, for GPIO-driven buttons */ unsigned int irq; + unsigned int wakeup_trigger_type; spinlock_t lock; bool disabled; bool key_pressed; @@ -540,6 +542,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev, } if (bdata->gpiod) { + bool active_low = gpiod_is_active_low(bdata->gpiod); + if (button->debounce_interval) { error = gpiod_set_debounce(bdata->gpiod, button->debounce_interval * 1000); @@ -568,6 +572,24 @@ static int gpio_keys_setup_key(struct platform_device *pdev, isr = gpio_keys_gpio_isr; irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING; + switch (button->wakeup_event_action) { + case EV_ACT_ASSERTED: + bdata->wakeup_trigger_type = active_low ? + IRQ_TYPE_EDGE_FALLING : IRQ_TYPE_EDGE_RISING; + break; + case EV_ACT_DEASSERTED: + bdata->wakeup_trigger_type = active_low ? + IRQ_TYPE_EDGE_RISING : IRQ_TYPE_EDGE_FALLING; + break; + case EV_ACT_ANY: + /* fall through */ + default: + /* + * For other cases, we are OK letting suspend/resume + * not reconfigure the trigger type. + */ + break; + } } else { if (!button->irq) { dev_err(dev, "Found button without gpio or irq\n"); @@ -586,6 +608,11 @@ static int gpio_keys_setup_key(struct platform_device *pdev, isr = gpio_keys_irq_isr; irqflags = 0; + + /* + * For IRQ buttons, there is no interrupt for release. + * So we don't need to reconfigure the trigger type for wakeup. + */ } bdata->code = &ddata->keymap[idx]; @@ -718,6 +745,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-event-action", + &button->wakeup_event_action); + button->can_disable = fwnode_property_read_bool(child, "linux,can-disable"); @@ -845,19 +875,112 @@ static int gpio_keys_probe(struct platform_device *pdev) return 0; } +static int __maybe_unused +gpio_keys_button_enable_wakeup(struct gpio_button_data *bdata) +{ + int error; + + error = enable_irq_wake(bdata->irq); + if (error) { + dev_err(bdata->input->dev.parent, + "failed to configure IRQ %d as wakeup source: %d\n", + bdata->irq, error); + return error; + } + + if (bdata->wakeup_trigger_type) { + error = irq_set_irq_type(bdata->irq, + bdata->wakeup_trigger_type); + if (error) { + dev_err(bdata->input->dev.parent, + "failed to set wakeup trigger %08x for IRQ %d: %d\n", + bdata->wakeup_trigger_type, bdata->irq, error); + disable_irq_wake(bdata->irq); + return error; + } + } + + return 0; +} + +static void __maybe_unused +gpio_keys_button_disable_wakeup(struct gpio_button_data *bdata) +{ + int error; + + /* + * The trigger type is always both edges for gpio-based keys and we do + * not support changing wakeup trigger for interrupt-based keys. + */ + if (bdata->wakeup_trigger_type) { + error = irq_set_irq_type(bdata->irq, IRQ_TYPE_EDGE_BOTH); + if (error) + dev_warn(bdata->input->dev.parent, + "failed to restore interrupt trigger for IRQ %d: %d\n", + bdata->irq, error); + } + + error = disable_irq_wake(bdata->irq); + if (error) + dev_warn(bdata->input->dev.parent, + "failed to disable IRQ %d as wake source: %d\n", + bdata->irq, error); +} + +static int __maybe_unused +gpio_keys_enable_wakeup(struct gpio_keys_drvdata *ddata) +{ + struct gpio_button_data *bdata; + int error; + int i; + + for (i = 0; i < ddata->pdata->nbuttons; i++) { + bdata = &ddata->data[i]; + if (bdata->button->wakeup) { + error = gpio_keys_button_enable_wakeup(bdata); + if (error) + goto err_out; + } + bdata->suspended = true; + } + + return 0; + +err_out: + while (i--) { + bdata = &ddata->data[i]; + if (bdata->button->wakeup) + gpio_keys_button_disable_wakeup(bdata); + bdata->suspended = false; + } + + return error; +} + +static void __maybe_unused +gpio_keys_disable_wakeup(struct gpio_keys_drvdata *ddata) +{ + struct gpio_button_data *bdata; + int i; + + for (i = 0; i < ddata->pdata->nbuttons; i++) { + bdata = &ddata->data[i]; + bdata->suspended = false; + if (irqd_is_wakeup_set(irq_get_irq_data(bdata->irq))) + gpio_keys_button_disable_wakeup(bdata); + } +} + static int __maybe_unused gpio_keys_suspend(struct device *dev) { struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev); struct input_dev *input = ddata->input; - int i; + int error; 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) - enable_irq_wake(bdata->irq); - bdata->suspended = true; - } + error = gpio_keys_enable_wakeup(ddata); + if (error) + return error; } else { mutex_lock(&input->mutex); if (input->users) @@ -873,15 +996,9 @@ static int __maybe_unused gpio_keys_resume(struct device *dev) struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev); struct input_dev *input = ddata->input; int error = 0; - int i; 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) - disable_irq_wake(bdata->irq); - bdata->suspended = false; - } + gpio_keys_disable_wakeup(ddata); } else { mutex_lock(&input->mutex); if (input->users) diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c index 8c6c0b9109c7..d69e631cfa0a 100644 --- a/drivers/input/keyboard/stmpe-keypad.c +++ b/drivers/input/keyboard/stmpe-keypad.c @@ -48,6 +48,14 @@ #define STMPE_KEYPAD_KEYMAP_MAX_SIZE \ (STMPE_KEYPAD_MAX_ROWS * STMPE_KEYPAD_MAX_COLS) + +#define STMPE1601_NUM_DATA 5 +#define STMPE2401_NUM_DATA 3 +#define STMPE2403_NUM_DATA 5 + +/* Make sure it covers all cases above */ +#define MAX_NUM_DATA 5 + /** * struct stmpe_keypad_variant - model-specific attributes * @auto_increment: whether the KPC_DATA_BYTE register address @@ -74,7 +82,7 @@ struct stmpe_keypad_variant { static const struct stmpe_keypad_variant stmpe_keypad_variants[] = { [STMPE1601] = { .auto_increment = true, - .num_data = 5, + .num_data = STMPE1601_NUM_DATA, .num_normal_data = 3, .max_cols = 8, .max_rows = 8, @@ -84,7 +92,7 @@ static const struct stmpe_keypad_variant stmpe_keypad_variants[] = { [STMPE2401] = { .auto_increment = false, .set_pullup = true, - .num_data = 3, + .num_data = STMPE2401_NUM_DATA, .num_normal_data = 2, .max_cols = 8, .max_rows = 12, @@ -94,7 +102,7 @@ static const struct stmpe_keypad_variant stmpe_keypad_variants[] = { [STMPE2403] = { .auto_increment = true, .set_pullup = true, - .num_data = 5, + .num_data = STMPE2403_NUM_DATA, .num_normal_data = 3, .max_cols = 8, .max_rows = 12, @@ -156,7 +164,7 @@ static irqreturn_t stmpe_keypad_irq(int irq, void *dev) struct stmpe_keypad *keypad = dev; struct input_dev *input = keypad->input; const struct stmpe_keypad_variant *variant = keypad->variant; - u8 fifo[variant->num_data]; + u8 fifo[MAX_NUM_DATA]; int ret; int i; |